JVM Architecture in detail ?

JVM is stand for Java Virtual Machine.

JVM is the layered structured architecture which is responsible for execution of java code.

JVM Architecture includes components that are :

CLASS LOADER SUBSYSTEM

RUN TIME AREA

EXECUTION ENGINE

JAVA NATIVE INTERFACE

ADD ON : LIFE CYCLE OF CLASS : 1) Loading, 2) Linking, 3) Initialization, 4) Execution, 5) Instantiation, 6) Garbage Collection, 7) Finalization and 8) Unloading.

1 . CLASS LOADER SUBSYSTEM —> In class loader subsystem we have 3 phases i.e. LOADING, LINKING, INITIALIZATION.

1 LOADING : In Loading we have three type of loaders i.e. Application class loader, Extension class loader and Bootstrap class loader.

Application class loader: Work of Application class loader is to load all the User created class into the JVM. Extension class loader: Work of Extension class loader is to load all the JAR files. Bootstrap class loader: Work of Bootstrap class loader is to load all the predefined class into the JVM.

2 LINKING : In Linking phase we have 3 phases they are : Verify, prepare and resolve

Verify: In verification phase we have BytecodeVerifier which verify the .class file weather the .class file is correct or not if not the it throw an error. Prepare: In prepare phase all the variable is initialized with the default values And Memory is allocated for Static members. Resolve: In Resolve phase all the static block is executed.

3 INITIALIZATION : In that phase all the static block is executed.

2. JVM RUN TIME AREA

In JVM run time area we have 5 areas i.e. Method Area, Heap Area, Java Stack Area, Program Counter Register and Native Method Stack Area.

Method Area : In this area all the classes and and class object is loaded which includes constructor, static member, non static member, and modifiers. Heap Area : In this Area all the class object is created. JVM Stack Area : In this Area all the method is executed including static and non static. Program Counter Register: It stores the address of the current execution instruction. Native Method Stack Area: It stores the information about native Method.

3. EXECUTION ENGINE : In this phase we have 3 phase they are JIT Compiler, Interpreter, Garbage Collector.

JIT Compiler: It is used to increase the efficiency of the interpreter. It help the interpreter to boost up the compilation process. Interpreter: It interpret the code line by line and then executes. The disadvantage of interpreter is if we get error suppose in line 8 after solving that error it again compiler the code from line number 1 so it takes time. Garbage Collector: It is a automatic memory management process which destroys the unreferenced Object from the Heap area and allocate the memory for another Object.

4. JAVA NATIVE INTERFACE

It a collection of native libraries required for execution of native method which is written in another language like C and C++.