JVM (Java Virtual Machine) Architecture | infoStud blogs

JVM (Java Virtual Machine) is a theoretical machine. It is known as a virtual machine since it doesn't truly exist. It is a determination that gives a runtime climate in which Java bytecode can be executed. It can likewise run those projects which are written in different dialects or language and aggregated to Java bytecode. 

What is JVM

It is:

  • A determination where the working of Java Virtual Machine is indicated. Yet, the execution supplier is autonomous to pick the calculation or algorithm. Its execution has been given by Oracle and different organizations. 
  • An execution Its execution is known as JRE (Java Runtime Environment). 
  • Runtime Instance Whenever you compose java program on the command prompt to run the java class, an instance of JVM is made.

What it does

The JVM performs the following operation:

  • Load code 
  • Checks code 
  • Executes code 
  • Gives runtime climate or environment

JVM Architecture

Now let's understand the internal structure of JVM. It contains the classloader, memory area, etc.


JVM (Java Virtual Machine) Architecture

1) Classloader

Classloader is a subsystem of JVM which is utilized to stack class records or files. At whatever point we run the java program, it is stacked first by the classloader. There are three implicit classloaders in Java. 

  • Bootstrap ClassLoader: This is the first classloader which is the superclass of the Extension classloader. It stacks or loads the rt.jar file which contains all class files or documents of Java Standard Edition like java.lang bundle classes, java.net bundle classes, java.util bundle classes, java.io bundle classes, java.sql bundle classes and so on.
  • Expansion ClassLoader: This is the youngster or child classloader of Bootstrap and parent classloader of System classloader. It loads the jar files situated inside $JAVA_HOME/jre/lib/ext registry. 
  • System/Application ClassLoader: This is the Child classloader of Extension classloader. It stacks the classfiles from the classpath. Naturally, the classpath is set to the current catalog. You can change the classpath utilizing "- cp" or "- classpath" switch. It is otherwise called Application classloader.

2) Class(Method) Area 

Class(Method) Area stores per-class constructions or structures, for example, the runtime constant pool, field and metadata. 

3) Heap 

It is the runtime data region in which objects are dispensed. 

4) Stack 

Java Stack stores outlines or frames. It holds local variables and partial outcomes and has an impact on strategy summon and return. 

Each thread has a private JVM stack, made simultaneously as a thread. 

Another frame is made each time a strategy is summoned. An edge is obliterated when its strategy summons finishes. 

5) Program Counter Register 

PC (program counter) register contains the location of the Java virtual machine guidance right now being executed. 

6) Native Method Stack 

It contains every one of the local or native method utilized in the application. 

7) Execution Engine 

It contains: 

  • A virtual processor 
  • Mediator: Read bytecode stream at that point execute the guidelines. 
  • Just-In-Time(JIT) compiler: It is utilized to improve the exhibition. JIT aggregates portions of the byte code that have comparable usefulness simultaneously, and thus lessens the measure of time required for assemblage. Here, the expression "compiler" alludes to an interpreter from the guidance set of a Java virtual machine (JVM) to the guidance set of a particular CPU. 

8) Java Native Interface 

Java Native Interface (JNI) is a system that furnishes an interface to speak with another application written in another dialect like C, C++, Assembly and so forth Java utilizes JNI structure to send yield to the Console or collaborate with OS libraries.


Post a Comment

0 Comments