Java virtual machine (JVM) by R4R Team

Java virtual machine (JVM):

A JVM stand for Java virtual machine is an implementation of the Java Virtual Machine Specification, interprets compiled Java binary code (called bytecode) for a computer's processor (or "hardware platform") so that it can perform a Java program's instructions. JVMs are available for many hardware and software platforms (i.e.JVM is plateform dependent).

In the order to write and execute a software program you need the following:

1) Editor – To type your program into , a notepad could be used for this

2) Compiler –
To convert your high language program into native machine code

3) Linker – To combine different program files reference in your main program together.

4) Loader –
To load the files from your secondary storage device like Hard Disk , Flash Drive , CD into RAM for execution. The loading is automatically done when your execute your code.

5) Execution –
Actual execution of the code which is handled by your OS & processor.

The Basic Parts of the Java Virtual Machine:

Creating a Virtual Machine within our computer's memory requires building every major function of a real computer down to the very environment within which programs operate. These functions can be broken down into seven basic parts:

The JVM performs following operation:

Loads code
Verifies code
Executes code
Provides runtime environment


JVM provides definitions for the:

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

Java virtual machine and its architecture: below diagram show the architecture of JVM....

 

 


In ,JVM has various sub components internally. You can see all of them from the above diagram.


1. Class loader sub system: JVM's class loader sub system performs 3 tasks
a. It loads .class file into memory.
b. It verifies byte code instructions.
c. It allots memory required for the program.

2. Run time data area: This is the memory resource used by JVM and it is divided into 5 parts

a. A method storage area: Method area stores class code and method code.

b. A Heap: Objects are created on heap.

c. A Java stacks: Java stacks are the places where the Java methods are executed. A Java stack contains frames. On each frame, a separate method is executed.

d. Program counter registers: The program counter registers store memory address of the instruction to be executed by the micro processor.

e. Native method stacks: The native method stacks are places where native methods (for example, C language programs) are executed. Native method is a function, which is written in another language other than Java.

3. Native method interface: Native method interface is a program that connects native methods libraries (C header files) with JVM for executing native methods.

4. Native method library:
holds the native libraries information.

5. An Execution environment:
Execution engine contains interpreter and JIT compiler, which covert byte code into machine code. JVM uses optimization technique to decide which part to be interpreted and which part to be used with JIT compiler. The HotSpot represent the block of code executed by JIT compiler.

Leave a Comment:
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!