Main Components of JVM

Moveena Kumari
3 min readMar 7, 2022

JVM (Java Virtual Machine)consists of 03 main components.

  • Class Loader
  • Memory Area
  • Execution Engine
Main Components of JVM

Class Loader

Class loader is responsible for loading the .class file of a java file into the memory area.

When loaded into memory area it’s creates an object from “class type” (Special data type in Java). Only one object per class could create. (Only in very first time). Class loader also consist of 03 sub parts.

  • Loading
  • Linking
  • Initialization

~Loading

When loading the class file into memory area it’s going to check the following information of that particular file.

  • Full qualified name
  • Whether it’s a class / interface
  • Immediate parent class information
  • Instance variable information

~Linking

Linking also have 03 sub steps such as,

  • Verification

For verification process JVM has a byte code verifier. It checks,

  1. If the code has come from a valid complier
  2. If the code has the correct structure
  3. If the code has correct formatting

If those conditions are not satisfied JVM will throw an exception called “Verifier Exception”. If everything is done and no exceptions were found then the verification process is completed.

  • Preparation

In preparation process, if you have any instance or static variables in your program it assign default values for those variables.(This is a default value not a initial value)

  • Resolution

In resolution process, before reach to the machine level JVM replacing those (domain specific words) symbolic link with direct link with the allocated memory address. (Because, JVM cannot understand those domain specific words. Such as, Student , Employee).

~Initialization

In initialization it assign real value to static variables and it will execute your static block. Every class must be initialize before it’s active use.

Ways of active use for Java class,

  1. Using new keyword
  2. Invoke a static method — (employee.verify())
  3. Assign values for static field
  4. Initial class — Main
  5. Usage of reflection — getInstance
  6. Instantiating subclass

Memory Area

Memory area has 05 more sub areas with it,

  • Method Area

This consists all the information regarding class names, parent class details, method /static variables.

  • Heap Area

This area has all the details regarding objects.

Note : Each and every JVM instance only have one method and heap area

  • Stack

This area consists of all the details about methods and local variables.

  • PC Register

This will hold the information about next execution.

Note : Stack and PC Register will create per thread.

  • Native Method Area

Any native methods that are to be loaded are listed in the native method section.

Execution Engine

Execution engine has 03 sub sections as well.

  • Interpreter
  • JIT Compiler
  • Garbage Collection

References

--

--