THE ARCHITECTURE OF THE JVM.
Architecture of JVM
1. Class
loader.
2. Byte
code verifier.
3. Memory
area.
i.
Class area.
ii.
Heap area.
iii.
Stack area.
iv.
Native area.
v.
PC register.
4. Execution engine. |
1.
Class
loader
Class
loader is the utility in the JVM which is responsible to load the .class file from hard disk to JVM.
There are
Three Types of class Loader
1.1
Boot
Strap class loader
1.2 System
class loader
1.3 Extended
class loader
1.1
Boot
Strap class loader
·
Boot strap class loader loads the .class
file from the java library available in the JRE.
C:\Program
Files\java\jdk1.8.0\jre\lib\rt.jar
a. .jar
file is the compressed file.
b. rt.jar file contains
the approximately 5000 classes within the different packages.
[Note: - If were using
the class of the java library in our class then all that classes also gets
loaded in the JVM.]
For Ex: - In the last
program System class, Sting class
and Integer class are the library
classes that we were using in our Test class.
·
Along with our test class there are
three library classes also gates loaded into the JVM.
1.2 System
class loader
·
System class loader is responsible to
load the user define classes from the class path.
·
The current directory that we are opened
in the DOS is the default class path.
1.3 Extended
class loader
This
class loader will load the .class file from the jre\lib\ext folder.
C:\Program
Files\Java\jdk1.8.0\jre\lib\ext
In the ext folder the .class file should not be placed directly rather
must be placed within the .jar file.
Jar
tool in java is use to make a .jar file and also use to uncompress the .jar
file.
.jar tool
is also available in the
C:\Program
Files\Java\jdk1.8.0\jre\bin
Steps to make the .jar file
Step 1: - prepare the
.class file by the javac these are the .class file that we want to move in the
.jar file.
C:\java>javac abc.java
.class will be generated.
Step 2: -Execute the jar
command
Step 3: - After creating
the sample.jar file just place it in
the jre\lib\ext folder.
Step 4: - Delete the
.class file from the current directory
That
contains main method
Step 6: - System class
loader becomes fail to load Test.class
but extended class loader will load successfully from
C:\Program
Files\java\jdk1.8.0\jre\bin\ext\sample.jar
Sequence of
the class loader to load any class
1. Extended
class loader.
2. System
class loader.
3. Boot strap class loader
3. Boot strap class loader
2.
Byte
code verifier
·
Byte code verifier is the tool in the
JVM that verify to the code of the .class file loader by the class loader
·
In the content in the .class file is
found correct by the byte code verifier than the content of the .class file
copied into the memory area of the JVM.
3.
Memory
area
Memory
area in JVM there are five types of memory areas in the JVM
3.1 Class
area
3.2 Heap
area
3.3 Stack
area
3.4 Native
area
3.5. PC register
3.1 Class
area
·
Class areas in the JVM are used to hold
the .class file which is loaded by the class loader.
·
They are only one class area in the JVM
which is shared by all the threads.
3.2 Heap
Area
All the objects always are
created in the heap area.
There is only one heap area as
per JVM which is shared by all the thread running in the JVM.
3.3 Stack
Area
Stack area is used in the method
execution.
That means when any method is
invoked then immediately a new frame is created in the stack and as the method
completed then the frame of that method gets destroyed.
Stack area |
[Note: - There is the
separate stack in the JVM for the separate threads.]
3.4 Native Area
·
Native area in the JVM is use to contain
the native code.
·
A native code is the code written in
java in the special manner by using the JNI
(Java native Interface).
·
Through the native code is the function
of the C & C++ can be invoked.
·
In the operating system the internal
library is developed in the C language that is invoked by JVM through the
native code.
·
There is a separate native code for the
separate thread.
3.5 PC
Register
·
A PC register contains the next
instruction to be executed.
·
There are shape rate PC register for
each thread.
4. Execution engine.
The bytecode that is assigned to the runtime data areas in the JVM via class loader is executed by the execution engine. The execution engine reads the Java Bytecode in the unit of instruction. It is like a CPU executing the machine command one by one.
No comments:
Post a Comment