JVM(Java Virtual Machine) is not a machine, it is a program and is the heart of the entire java program execution process. It is responsible for taking .class file and converting each byte code instruction into the machine language instruction that can be executed by the microprocessor.
Class Loader Subsystem
In JVM, there is a program or module named as Class loader subsystem, which performs the following functions
- It loads the .class file into the memory
- Verifies the byte code instructions
- Allocates necessary memory to execute the program
This memory is divided into five parts, called run-time data areas which contain the data and results while running the program.
It is a memory block that stores the class code, code of the variables, and methods in the java program.
This is the area where objects are created and whenever JVM loads a class, method and heap area are immediately created in it.
While running a method, it needs some more memory to store data and results. This memory is allocated on java stacks.
PC (Program Counter) Register
This contains the memory address of the instructions of the methods.
Native Method Stacks
Native methods are executed on native method stacks.
It stands for Just In Time compiler. It is the part of JVM which increases the speed of execution of a java program. The execution engine contains both an interpreter and JIT compiler which are responsible for converting byte code instructions into machine code so that the processor will execute them. Generally, any programming language(like C/C++) uses either interpreter or compiler to convert source code into machine code, but in JVM both the interpreter and compiler will work at the same time which increases the speed of execution. After loading the . class code into memory, JVM first analyzes or identifies which code is to be left to the interpreter and which one to the JIT compiler so that the performance is better. The block of code allocated to JIT is known as Hotspots.
Java Native Interface
To execute the native methods, generally, native method libraries( example C/C++ header files) are needed, these header files are located and connected to JVM by a program, called the native method interface.