CH-20-JVM Architecture
CH-20-JVM Architecture
Type of VM:
-----------
1. HW based / System Based VM:- used for effecting utilization of hardwares.
-------------------------------
ex: KVM(kernel based vm), VMware(virtual machine ware), Xen , Cloud computing
EX: 2.Linking
------------------------
A. Verification
|
1. Loading -> B. Preparation -> 3. Initialization
|
C. Resoluation
------------------------
1 Loading :
-----------
> loading means "reading" .class files and
storing corresponding Binary Data in "Method Area"
>for each class file jvm will store following info in method area.
a> Full qualified name of the Loaded class
b> Full qualified name of its immediate Parent class.
c> Modifiers info...
d> Variables info..
e> Methods info..
f> Constant Pool info.
IMP_Note:
---------
> after loading .class file , immediatally JVM will Creates an Object of Class
class Type on Heap memory
to represent class level binary infomation.
> The Class Object can be used by programmer to get Class level info like
ex: Full Qualified Name of class.
Parent class name
Methods and Variables info
Ex:
first - import java.lang.reflect.*;
//System.out.println("c.getName : "+s.getClass());
System.out.println("how get className : "+c.getName());
Method[] m=c.getDeclaredMethods();
for(int i=0; i<m.length; i++)
{
System.out.println("Method in your Class : "+m[i]);
}
Field[] f=c.getDeclaredFields();
for(int i=0; i<f.length; i++)
{
System.out.println("Variable in your class : "+f[i]);
}
}
---------------------------
Imp-Note:
---------
> for every loaded .class file only one Class obj will be created , not more than
one.
1. Verification:-
-----------------
>internally Byte Code Verifier which is part of Class Loader is responsible for
this activity.
>processing of ensuring that Binary representation of a class is structurally
Correc or not.
or .class file is properly formatted or not.
2. Preparation: imp
---------------
> in this phase, JVM will Allocate memory for class level static var and assign
default values not original values
Note:-> original values will be assigned in Initialization phase.
3. Resoluation:
---------------
> process of replaced Symbolic references with Original References.
Ex:
class Test
{
p.s.v.m(String[] args)
String s = new String();
Student s1 = new Student();
}
> in resoluation Phase these Names are replace with actual ref from Method area.
3 Initialization:
-----------------
>all Static var will be assigned with original values and
+
>static Blocks will be executed from top to bottom and from Parent to child.
ex:
2.Linking
------------------------
A. Verification
|
1. Loading -> B. Preparation -> 3. Initialization
|
C. Resoluation
------------------------
-----------------------------------------------------
1. BootStrapClassLoader: imp
------------------------
>responsible to load classes from -> jdk\jre\lib .*jar folder
>Notoe:-all core java api classes present in "rt.jar" , which is present in this
location,
so all api classes like String, StringBuffer will be loaded by BootStrap
class loader only.
----------------------------------------------------------------------------------
Q-what is Java.langClassLoaderClass?
-------------------------------------
>Java.langClassLoaderClass - acts as Base class for desining our own customized
classloader.
>every customized classloader should extends -Java.langClassLoaderClass. directally
or indirectally.
----------------------------------------------------------------
1. METHOD AREA: [total class level binary information including static var stored
in method area]
---------------
>created at the time of jvm start-up
>method area will be shared by all threads(global memory)
>method area shows runtime constant pool.
>total class level binary information including static var stored in method area
2. HEAP AREA: [prog view it considerd imp memory area, all (instance var's + obj
ref + object data) will be stored here]
-------------
>created at jvm start-up.
>heap area can be accessed by all threads or (its also shareable memory)
>note: array in java, also is an object so will be stored in Heap Memory only.
>all obj data will be stored in heap area.
Ex:
class HeapMemory
{
------------------------------------------------------------
-------------------------------------------------
3. JAVA STACK AREA: [all method calls+local var + results will be stored in
stack]
-------------------
>For every Thread-> JVM will create a seperate Runtime stack. and Runtime Stack
will be created Automatic at
the time of Thread creation.
>all method calls+local var + results will be stored in stack
>For every Method call -> a seperate entry will be added to stack , this entry
called 'stack frame'
and after completion method stack will be romoved.
>in last just before terminating thread, runtime stack will be destroyed by JVM.
1. Local var Array: [it contains slot/entry , and each slot/entry is 4 byte]
-------------------
>it contains all parameters and local var of method,
value of int, float, and ref var occupy 1 entry / 1 slot in that array,
Note:- long and double occupy 2 slot / 2 entry.
Note:- byte, short, char values will be converted to int before storing in slot and
occupy 1 sloat.
Note:- most of jvm follow 1 slotn for boolean value but its varied from jvm to jvm.
2. Operand stack:
-----------------
> operand stack is a work space for jvm,
3. Fram Data:
-------------
>all symbolic references (constant pool) related to that method.
>it contains ref to Exception table which provide correspondence catch block info
in case of exception.
Imp Note:
1-> Method area, Heap area, are considerd as major memory area with respect to
programmer point of view.
2-> Method area, Heap area, are for JVM,
Whereas
Stack Area, PC Register area and Native Method Area are used for Thread.
----------------------------------------------------------------------------
******EXECUTION ENGINE:
-----------------------
>its central component of JVM, responsible to execute java class files
Problum: - > it interprets every time even the same method even multiple times.
which reduce Perform of system.
Solved:- > introduced JIT compiler in 1.1 version.
2. JIT compiler:
----------------
>main perpose is to improve performance, because internally jit maintaine a seprate
count for every method.
>always First method will be interpreted normally by interpreter jit increment the
count var.
this process will be continued for every method.
>if any method comes to Threshold value (starting point for a new thread)
then jit identify that method repeately used , immmediataly jit compiles that
method and generate Native code
Next time jvm come across that method call then jvm direct use Native code
means comiler will not compile again this so performance will be improved.
===================================================================================
============