The Java Virtual Machine is a platform independent abstract machine. It is particularly responsible for creating a run-time environment that is conducive for byte code to execute efficiently. As it is platform-independent, JVM can be used for a series of hardware and software platforms.
Table of Contents
What is JVM?
- It is a specification that determines how bytecode will be processed in various hardware and software. The implementation provider is, however, free to choose from any algorithm. As JAVA is owned by Oracle currently, the company dictates the implementation conventions.
- The JVM creates a runtime environment called the Java Runtime Environment (JRE).
- Whenever a Java code is executed or a command is entered in the command prompt, Java creates an instance of the JVM.
What the JVM does?
The Java Virtual Machine performs the following operations:
- Loads the code as an instance of the JVM is created whenever the code begins to compile.
- The JVM then verifies the code.
- Executes the code by using the bytecode provided by the compiler.
- Creates a runtime environment (JRE).
JVM also provides definitions for the following:
- Memory Area
- Class file format
- Register Set
- Garbage-collected Heap
- Fatal error reporting etc.
JVM Architecture
The JVM Architecture can be broken down in the following components:
- Classloader – As the name suggests, the classloader loads the class files whenever a new program is executed. There are three in-built classloaders in Java namely Bootstrap ClassLoader, Extension ClassLoader, and System/Application ClassLoader.
- Class (Method) Area – This is a designated area for the current class components under execution.
- Heap – Objects are allocated here.
- Stack – Java Stack stores local variables and frames.
- Program Counter Register – It contains the address of the JVM.
- Native Method Stack – Contains all the native methods.
- Execution Engine – Contains a virtual processor, interpreter, and a Just in Time (JIT) compiler.
0 Comments