#JVM(Java Virtual Machine)

Siddhi Patil
2 min readJul 30, 2020
  1. JVM(Java Virtual Machine) acts as a run-time engine to run Java applications.
  2. JVM is the one that actually calls the main method present in a java code.
  3. JVM is a part of JRE(Java Runtime Environment).

Class Loader Subsystem-

  1. Loading
  2. Linking
  3. Initialization

JVM Memory-

  • Method area :
  1. In method area, all class level information like class name, immediate parent class name, methods and variables information etc. are stored, including static variables.
  2. There is only one method area per JVM, and it is a shared resource.
  • Heap area :
  1. Information of all objects is stored in heap area.
  2. There is also one Heap Area per JVM.
  3. It is also a shared resource.
  • Stack area :
  1. For every thread, JVM create one run-time stack which is stored here.
  2. Every block of this stack is called activation record/stack frame which store methods calls.
  3. All local variables of that method are stored in their corresponding frame.
  4. It is not a shared resource.
  • Native method stacks :
  1. For every thread, separate native stack is created. It stores native method information.
  • Execution Engine
  1. Execution engine execute the .class (bytecode).
  2. It reads the byte-code line by line, use data and information present in various memory area and execute instructions.
  3. It can be classified in three parts :-
  • Interpreter :
  1. It interprets the bytecode line by line and then executes.
  2. The disadvantage here is that when one method is called multiple times, every time interpretation is required.
  • Just-In-Time Compiler(JIT) :
  1. It is used to increase efficiency of interpreter.
  2. It compiles the entire bytecode and changes it to native code so whenever interpreter see repeated method calls,JIT provide direct native code for that part so re-interpretation is not required,thus efficiency is improved.
  • Garbage Collector :
  1. It destroy un-referenced objects.For more on Garbage Collector,refer Garbage Collector.

Java Native Interface (JNI) :

  • It is an interface which interacts with the Native Method Libraries and provides the native libraries(C, C++) required for the execution.
  • It enables JVM to call C/C++ libraries and to be called by C/C++ libraries which may be specific to hardware

Native Method Libraries :

  • It is a collection of the Native Libraries(C, C++) which are required by the Execution Engine

--

--