JVM Architecture
JVM is the part of JRE and it is responsible to load and run Java class files.
Basic Architecture diagram of JVM
Class loader sub system:
It is responsible for the following three activities
- Loading
- Linking
- Initialization
1. Loading
Loading means reading class files and store corresponding binary data in method area. For each class file JVM will Store corresponding information in the method area.
- Fully qualified name of class
- Fully qualified name of immediate parent class
- Method information
- Variable information
- Constructor information
- Modifier information
- Constant pool information
The Class class object can be used by programmer to get class level information like method, variable and constructor information etc.
Ex:
Note:
For every loaded type only one class object will be created even though we are using class multiple times in our program
2. Linking
Linking perform 3 activities
- Verify
- Prepare/ Preparation
- Resolve/ resolution
Verify
- It is the process of insuring that binary representation of a class is structurally correct or not. i.e. JVM will check whether the dot class file generated by valid compiler or not and properly formatted or not with the help of bytecode verifier.
- bytecode verifier is a part of the class loader subsystem.
- If verification fails then we will get Runtime exception saying: java.lang.VerifyError.
Preparation
- In this phase JVM will allocate memory for class level static variables and assign default values
Note: In initialization phase original values will be assigned to the static variable and here only default value will be assigned.
Resolve/ Resolution
It is the process of re-planning symbolic names in our program with original memory reference from method area.
Ex:
class Test
{
public static void main(String[] agrs)
{
String s1= new String("Raka");
Student s2 = new Student();
}
}
For the Test program .class loader loads
- Test.class
- String.class
- Student.class
- Object.class
the name of the three classes are constant pool of test class. In resolution phase these names are replace with original memory level references from method area.
3. Initialization
In this all static variables are assigned with original value and static blocks will be executed from parent to child and from top to bottom.
Note: while loading, linking and initialization if any error occurs then we will get Runtime exception saying java.lang.LinkageError.
VerifyError is child class of LinkageError
Related Post
JVM Architecture : Virtual Machine in Java
Casino Site - Lucky Club
ReplyDeleteAll you have to do is register and get your welcome bonus. To claim this bonus, simply click on luckyclub.live 'Join Now' and start gambling online. It will appear