e01.org

Java virtual machine

A Java virtual machine (JVM) is a virtual machine that enables a computer to run Java programs as well as programs written in other languages, referred to as JVM languages, that are also compiled to Java bytecode. The JVM is detailed by a specification that formally describes what is required in a JVM implementation. Having a specification ensures interoperability of Java programs across different implementations so that program authors using the Java Development Kit (JDK) need not worry about idiosyncrasies of the underlying hardware platform. The JVM reference implementation is developed by the OpenJDK project as open source code and includes a JIT compiler called HotSpot. The commercially supported Java releases available from Oracle are based on the OpenJDK runtime. Eclipse OpenJ9 is another open source JVM for OpenJDK.

A Java virtual machine (JVM) is a virtual machine that enables a computer to run Java programs as well as programs written in other languages, referred to as JVM languages, that are also compiled to Java bytecode. The JVM is detailed by a specification that formally describes what is required in a JVM implementation. Having a specification ensures interoperability of Java programs across different implementations so that program authors using the Java Development Kit (JDK) need not worry about idiosyncrasies of the underlying hardware platform. The JVM reference implementation is developed by the OpenJDK project as open source code and includes a JIT compiler called HotSpot. The commercially supported Java releases available from Oracle are based on the OpenJDK runtime. Eclipse OpenJ9 is another open source JVM for OpenJDK. ==JVM specification== The Java virtual machine is an abstract (virtual) computer defined by a specification. It is a part of the Java Runtime Environment. The garbage collection algorithm used and any internal optimization of the Java virtual machine instructions (their translation into machine code) are not specified. The main reason for this omission is to not unnecessarily constrain implementers. Any Java application can be run only inside some concrete implementation of the abstract specification of the Java virtual machine. Starting with Java Platform, Standard Edition (J2SE) 5.0, changes to the JVM specification have been developed under the Java Community Process as JSR 924. , changes to the specification to support changes proposed to the class file format (JSR 202) are being done as a maintenance release of JSR 924. The specification for the JVM was published as the blue book, whose preface states: The most commonly used Java virtual machine is Oracle's HotSpot. Oracle owns the Java trademark and may allow its use to certify implementation suites as fully compatible with Oracle's specification. ===Garbage collectors=== Garbage collectors available in Java OpenJDKs virtual machine (JVM) include: Serial Parallel CMS (Concurrent Mark Sweep) G1 (Garbage-First) ZGC (Z Garbage Collector) Epsilon Shenandoah GenZGC (Generational ZGC) GenShen (Generational Shenandoah) IBM Metronome (only in IBM OpenJDK) SAP (only in SAP OpenJDK) Azul C4 (Continuously Concurrent Compacting Collector) (only in Azul Systems OpenJDK) Java's design philosophy revolves around the assumption of a garbage collector. Unlike languages such as C++ and Rust, deterministic memory management through a delete keyword (as in C++) is not possible. Even introducing such a feature is not possible, due to a lack of ownership, aside from using or through to allocate/deallocate memory outside the Java heap. Due to Java primarily using heap-based allocation, objects are stored as references, and deletion would result in dangling pointers. Foo a = new Foo(); Foo b = a; delete a; System.out.println(b); ==JVM in the web browser== At the start of the Java platform's lifetime, the JVM was marketed as a web technology for creating Rich Web Applications. , most web browsers and operating systems bundling web browsers do not ship with a Java plug-in, nor do they permit side-loading any non-Flash plug-in. The Java browser plugin was deprecated in JDK 9. The NPAPI Java browser plug-in was designed to allow the JVM to execute so-called Java applets embedded into HTML pages. For browsers with the plug-in installed, the applet is allowed to draw into a rectangular region on the page assigned to it. Because the plug-in includes a JVM, Java applets are not restricted to the Java programming language; any language targeting the JVM may run in the plug-in. A restricted set of APIs allow applets access to the user's microphone or 3D acceleration, although applets are not able to modify the page outside its rectangular region. Adobe Flash Player, the main competing technology, works in the same way in this respect. according to W3Techs, Java applet and Silverlight use had fallen to 0.1% each for all web sites, while Flash had fallen to 10.8%. ===JavaScript JVMs and interpreters=== Since May 2016, JavaPoly allows users to import unmodified Java libraries, and invoke them directly from JavaScript. JavaPoly allows websites to use unmodified Java libraries, even if the user does not have Java installed on their computer. ===Transpilation to JavaScript=== With the continuing improvements in JavaScript execution speed, combined with the increased use of mobile devices whose web browsers do not implement support for plugins, there are efforts to target those users through transpilation to JavaScript. It is possible to either transpile the source code or JVM bytecode to JavaScript. Compiling the JVM bytecode, which is universal across JVM languages, allows building upon the language's existing compiler to bytecode. The main JVM bytecode to JavaScript transpilers are TeaVM, the compiler contained in Dragome Web SDK, Bck2Brwsr, and j2js-compiler. Leading transpilers from JVM languages to JavaScript include the Java-to-JavaScript transpiler contained in Google Web Toolkit, J2CL, Clojurescript (Clojure), GrooScript (Apache Groovy), Scala.js (Scala) and others. ==See also== ==Notes== ==References== Clarifications and Amendments to the Java Virtual Machine Specification, Second Edition includes list of changes to be made to support J2SE 5.0 and JSR 45 JSR 45 , specifies changes to the class file format to support source-level debugging of languages such as JavaServer Pages (JSP) and SQLJ that are translated to Java

source: e01 Encyclopedia · licence: CC BY-SA 4.0 · page · source revision

Cite this

"Java virtual machine". 1789532237. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1375173881

JSON record · API collection · citation policy