Tuesday, July 2, 2019

The Java Virtual Machine

JVM  (Java Virtual Machine) is an abstract machine. It is a specification that provide runtime environment in which java bytecode can be executed.
JVM are available for many hardware and software platforms(i.e. JVM is platform dependent.


What is JVM 

  • It is a specification where working of Java Virtual Machine is specified. But implementation provider is independent to choose the algorithm. Its implementation has been provided by Sun and other companies.
  • It is an implementation its implementation is known as JRE(Java Runtime Environment.
  • It is runtime instance whenever you write java command on the command prompt to run the java class, an instance of JVM is created.     

JVM provide definition for the:

  • Memory area .
  • Class file format
  • Resister set.
  • Garbage-collected heap.
  • Fatal error reporting etc.


Internal Architecture of JVM





Classloder is a subsystem of JVM that is used to load class file.

Class Area

Class Area stores per-class structure such as the runtime constant pool,field and method data, the code for methods.

Heap 

It is runtime data area in which objects are allocated.

Stack

Java Stack stores frames. It holds local variable and partial result, and plays a part in method invocation and return.
Each thread has a private JVM stack, created at the same time as thread.
A new frame is created each time a method is invoked. A frame is destroyed when its method invocation completes.  

Program Counter Register

PC(Program Counter) resister. It contain the address of java virtual machine instruction currently being executed .

Native Method Stack 

It contains all native methods used in application.

Execution Engine

It contains:
  1. A virtual processor 
  2. Interpreter 
  3. Just-In-Time(JIT) Compiler.





No comments:

Post a Comment

                                    ARRAY IN JAVA Normally, array is a collection of similar type of elements that have contiguous memo...