JVM Architecture.

In this article,JVM Architecture is explained in detail with examples.
JVM Architecture-Javaform

JVM stands for "Java virtual machine". It is an intelligent piece of software developed by Sun Micro Systems,which is responsible for many features of Java.Such as 
  • Portable.
  • Robust.
  • Platform independent.
  • Architecture Neutral.
  • Interpreted language.
  • High performance.
  • Secure. (From topic JVM Architecture)
JVM is responsible for running your Java program by allocating memory to your classes in RAM.
.Class Files.
When a Java program is compiled,for every class in our program, we get .class files also known as
"Bytecode". This bytecode is understood only by JVM for running your main program.
Class loader Sub-System.
It is a small piece of the program, which is responsible for loading all .class files of your program from hard disk into the memory of a program.
JVM Runtime Data Area.
After loading all the .class files into the memory of a program,different entities in our program classes are allocated with memory in different sections.This is known as "JVM Runtime Data Area".
It is divided into 5 sections,
JVM Runtime Data Area-Javaform
Method Area.
This area stores all meta-information or general information about a class.
Ex
A class or abstract class or interface
How many classes?
How many data members and their datatypes,modifiers etc.
How many methods and their return type,parameters,modifiers etc..,
How many and what are the base classes?
In this area,Static -variables and static methods are allocated memory i.e, common content.
Hence this area is also known as "Class segment  area". (From topic JVM Architecture)
Stack Area.
In this area, object-reference-variables are allocated with memory,containing object-reference-codes of Hashtable in Heap area.
This area also contains local variables of different methods as stacks. 
Heap Area.
This area is also known as "Object segment area" because each object is allocated with memory in this area.
All "instance variables" or non-static data members of a class are allocated with memory in this area.
Also, non-static methods are allocated with memory in this area.
Note
  • In Heap Area,JVM Maintains a table with 2 columns known as Hashtable.
  • 1st column is "object-reference-code" and 2nd column is "Hash-code".
  • Hashcode is a 32-bit unique integer generated by JVM for every physical object.This code is like a pointer to the object in Heap area.
  • Object-reference-code is a hexadecimal number referring to one unique hash code for one particular object in heap area. (From topic JVM Architecture)
Program counter area.
This area maintains different program counter points i.e, at which line, in which method, in which class program is getting executed.
It also stores counter-variables of loops for speedy execution of the program.
Native method area.
This area allocates memory for all native methods and its local variables being used in a program.
This area maintains separate memory for different native methods,so that for every method, a stack is maintained to store local variables.
Student s1=new Student(); //s1,s2,s3 are object reference varibles.
Student s2=new Student(); // new Student() is known as physical objects.
Student s3=new Student();
Native Method libraries.
Library files used in our Java program whose functions are implemented in C/C++ like other languages are provided to our program by JVM. (From topic JVM Architecture)
Native method Libraries-Javaform
Native Method Interfaces.
For the above native library files,JVM provides interfaces i.e, understanding classes.These mediator classes understand C/C++ native library functions and use them in our java program by allocating memory, in Native method area(stacks). (From topic JVM Architecture)
Interpreter.
It is a small piece of program which converts byte code into machine understandable code based on OS and hardware architecture of system line by line,by using Os library files necessary for our program.
Execution Engine.
Such Machine code is executed line by line using a small piece of a program known as execution engine with the help of OS and provides the required output.
Just in time compiler(JIT).
It stands for Just In Time compiler.This is a small program used by execution engine to increase the speed of execution by executing repetition codes like loops,recursions etc.
Ex
//program related to JVM Architecture-- object reference codes and hash codes.
class A
{
}
class B
{
}
class Student
{
}
class Hashcode
{
public static void main(String args[])
{
A obj=new A();
B obj1=new B();
Student s=new Student();
System.out.println("object reference codes: ");
System.out.println(obj);
System.out.println(obj1);
System.out.println(s);
System.out.println("HashCodes");
System.out.println(obj.hashCode());
System.out.println(obj1.hashCode());
System.out.println(s.hashCode());
}
}
Output
Hashcode-Output-Javaform
                               To get the code file use me. 

Continue to the next topic Inheritance in Java.

Begin your career in Digital Marketing,What is digital marketing? Digital Marketing online course. It's an current evolving technology which can give support to establish your own startup through Digital Marketing.

Do check my new startup Surprise Planners in HyderabadLavish Surprises our services are surprise party planners in Hyderabadsurprise giftssurprise birthday party planners Hyderabad, Wedding anniversary surprisessurprise planners Hyderabad.

Hi Friends, Please comment down your views in the comment section below. Thank you...

No comments:

Connect with Us by Subscribing here for more Updates..!

* indicates required