Java Virtual Machine Architecture

Java Virtual Machine (JVM)

Java Virtual Machine (JVM) is a platform-independent abstract computing machine. It is a virtual machine that converts Java byte code into machine language. JRE is the implementation of Java Virtual Machine (JVM).

After execution, this specification executes it.

  • Java byte code is the machine language for the Java Virtual Machine (JVM).
  • JVM also shield users from malicious programs.
  • Java Runtime Environment (JRE) has a Java Virtual Machine implementation with an implementation of the Java Class Library.

Following are the three notions of the Java Virtual Machine (JVM):

JVM Specification

As the name tells, specification is a document describing what is needed of a JVM implementation. It specifies the functioning of JVM.

JVM Implementation

It is a computer program that meets the requirements of the document describing the function of JVM i.e. Specification.

JVM Instance

It is an implementation running in a process which executes a computer program. This program is compiled into Java bytecode. Running of a Java Class, creates an instance of JVM.

JVM Architecture

Let’ see the components of JVM Architecture:

Java Virtual Machine Architecture

Class Loader

Class Loader does the work of loading, linking and initialization. It is a subsystem of JVM, which first loads the .class file. After loading, the linking is done. Linking includes verification of the .class file. At last, the initialization stage comes.

JVM Memory

It includes the memory areas allocated.

Method Area: Here, all the class level information is placed. It stores the class name, immediate parent class name, methods and variables information etc. The storage also includes the static variables.

Heap:  The Heap area is a share resource, which stores the Information of all the objects. There is only one Heap area per JVM.

JVM Language Stacks: JVM creates one run-time stack for every thread. The stack has blocks, which is called a stack frame, to store methods calls. The local variables of these methods get in their individual related frame.

On thread termination, the run-time stack also gets destroyed.

PC Registers: The store address of the JVM instruction currently being executed. Remember, each thread has separate registers.

Native Method Stacks: Native stack gets created for every thread. The stack also contains the native methods.

Execution Engine

It executes the .class file and has the following parts:

Interpreter: As the name tells, the Interpreter takes single instruction as input i.e. interprets bytecode line by line before execution.

Compiler:  In JAVA, Just-In-Compiler (JIT), comes enabled by default and leads to faster and execution code. It helps in solving the issues of using Interpreter. Interpreter needs to be executed again and again on method calling, whereas JIT compiles the entire bytecode once and improve the efficiency. When a method gets compiled, the JVM calls the compiled code of that particular method directly.

Java Native Interface (JNI)

It interacts with the Native Method Libraries and enables JVM to call libraries. It also provides the native libraries required for execution.

Native Method Libraries

The Native Method Libraries are a collection of the Native Libraries(C, C++) which are required by the Execution Engine.

Constructors in Java with Examples
Java Bitwise Operators
Studyopedia Editorial Staff
Studyopedia Editorial Staff
[email protected]

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading