Java Virtual Machine
The Java Virtual Machine (abbreviated to Java VM or JVM ) is the part of the Java Runtime Environment (JRE) for Java programs that is responsible for executing the Java bytecode . Normally, each started Java program is executed in its own virtual machine (VM). The other part of the Java runtime environment is the Java class libraries .
The JVM serves as an interface to the machine and the operating system and is available for most platforms (e.g. Linux , macOS , Palm OS , Solaris , Windows , z / OS , etc.). The JVM is mostly written in the programming languages C or C ++ .
The components of the JVM are
- the class loader ( classloader and resolver ),
- memory management and garbage collection ( garbage collection ), and the
- Execution engine .
Bytecode generated by the Java compiler ( platform-independent ) is executed by a platform-dependent Java virtual machine. The generated bytecode files (file extension “.class”) are translated into the local machine language during runtime . The virtual machine works like an interpreter , but is much faster, since z. B. no more syntax checks have to be made.
In addition to the platform independence of the bytecode, the Java Virtual Machine also offers increased security. It monitors the execution of the program at runtime, thus preventing, for example, buffer overflows , which lead to unpredictable behavior such as the program crashing. In the special case of Java, this monitoring is very simple, since Java does not directly support pointers (only implicitly).
The execution speed (English performance ) of Java programs to increase, most Java VMs place called JIT compiler on (JITC) immediately during program execution, the bytecode " J ust I n T " Just in time "ime" (, or "Just at the right time") permanently translate into machine code . A further development of this approach is the hotspot optimizer from Sun , which works with dynamic optimization.
Often at the time of compilation not known which specific input a software must process. As a result, the software has to deal with all types of input. The input is therefore saved in variables . After starting the program, however, many variables are no longer changed. As a result, these are constants from a point in time shortly after the start. If the software for the system architecture is only compiled after this point in time (this is the case with Java Hotspot), then these constants can be taken into account. Certain branches that are only dependent on such “half-constants” are then forever unique and therefore do not pose a risk of incorrect branch prediction . Such a program code can therefore run faster than code compiled at an earlier point in time.
Implementations in hardware
Foreclosure of the threads
The Java VM isolates the processes running in it from the operating system (green threads). By default, it maps Java threads to threads of the operating system. Thread management is only carried out by the Java VM in exceptional cases. This means that it is also possible to offer a Java VM with full functionality on an operating system that does not support multithreading.
The Java VM always has full and standard-compliant sovereignty over the Java threads, i. H. the programmer does not need to consider the operating system-specific multi-threading / tasking / processing properties and can always rely on the JRE . The disadvantage is that problems emanating from one thread are assigned to the entire process by the operating system. Common operating systems (such as Linux, Windows) allow control of these "native" threads, if necessary, using third-party software, such as the VisualVM supplied with the JDK . However, standard tools such as the Windows Task Manager do not display system threads.
Besides Java, there are also other languages that can be used as programming languages for JVM programs. The following languages, among others, can run on a JVM:
- Clojure , a Lisp dialect,
- Ceylon ,
- Concurnas, a multi-paradigm programming language for concurrent , distributed, and reactive applications, with Python-like syntax, support for GPU computing, and off-heap memory management.
- Erjang, an Erlang dialect for the JVM,
- Free Pascal , which also supports a large part of the Object Pascal constructs under the JVM ,
- Groovy , a very Java-like, statically and dynamically typed programming language
- JRuby , an almost Ruby- compatible implementation,
- Jython (formerly: JPython), a pure Java implementation of the Python programming language,
- Nice , complements Java with parametric types, anonymous functions, multi-methods, tuples and optional parameters.
- Scala , a language that combines features of Java with functional programming,
- Kotlin , a language introduced by JetBrains in 2011
- Dalvik - a JVM developed by Google for the Android platform
- HotSpot - the most widely used JVM from Oracle
- IBM J9
- JRockit ( BEA Systems , now Oracle )
- Kaffe - a free GPL JVM implementation
- Persistent Reusable Java Virtual Machine (PRJVM) - a form of the JVM modified by IBM
- PreonVM, virtual machine for resource-limited embedded systems
- SableVM - free LGPL JVM implementation
- Download page of the JRE (including the Java Virtual Machine) at Oracle
- JVM documentation at Oracle
- Specification of the Java VM (English)
- SPECjvm , the de facto standard for measuring the performance of a JVM
- Concurnas: the New Language on the JVM for Concurrent and GPU computing. In: InfoQ.com. C4Media Inc., accessed June 25, 2020 .
- The Concurnas Programming Language. Concurnas Ltd., accessed June 25, 2020 .
- The Nice programming language. Retrieved August 15, 2019 .
- Kotlin: First web presence for JetBrains JVM language , it- Republik.de, accessed July 22, 2012
- TeaVM: Build Fast, Modern Web Apps in Java. Retrieved October 23, 2019 .
- Dragome Web SDK. Retrieved October 23, 2019 .
- Bck2Brwsr - APIDesign. Retrieved October 23, 2019 .
- List of languages that compile to JS jashkenas / coffeescript Wiki GitHub. Github.com, accessed June 26, 2015 .
- PreonVM | Preon32 Series Virtual Machine. Retrieved November 10, 2017