SPIRO THE TECH GURU

Back

what is jvm in java?

By Admin on

JVM :


A Java virtual machine (JVM) is an abstract computing machine that enables a computer to run a Java program. There are three notions of the JVM: specification, implementation, and instance.

It is:

  1. A       specification where working of Java Virtual Machine is specified. But implementation provider is independent to choose the algorithm. Its implementation has been provided by Sun and other companies.
  2. An       implementation Its implementation is known as JRE (Java Run time Environment).
  3. Run  time       Instance Whenever you write java command on the command prompt to run the java class, and instance of JVM is created.

The JVM performs following operation:

  • Loads code
  • Verifies code
  • Executes code
  • Provides run time environment

Internal Architecture of JVM

Class loader:

One of the organizational units of JVM byte code is a class. A class loader implementation must be able to recognize and load anything that conforms to the Java class file format. Any implementation is free to recognize other binary forms besides class files, but it must recognize class files.

The class loader performs three basic activities in this strict order:

Loading: finds and imports the binary data for a type

Linking: performs verification, preparation, and (optionally) resolution

Verification: ensures the correctness of the imported type

Preparation: allocates memory for class variables and initializing the memory to default values

Resolution: transforms symbolic references from the type into direct references.

Initialization: invokes Java code that initializes class variables to their proper starting values.

Heap:

The Java virtual machine heap is the area of memory used by the JVM for dynamic memory allocation

Java byte code interpreter and just in time (JIT)compilers:

For each hardware architecture a different Java byte code interpreter is needed. When a computer has a Java byte code interpreter, it can run any Java byte code program, and the same program can be run on any computer that has such an interpreter.

When Java byte codeis executed by an interpreter, the execution will always be slower than the execution of the same program compiled into native machine language. This problem is mitigated by just-in-time (JIT) compilers for executing Java byte code. A JIT compiler may translate Java byte code into native machine language while executing the program. The translated parts of the program can then be executed much more quickly than they could be interpreted. This technique gets appliedto those parts of a program frequently executed. This way a JIT compiler cansignificantly speed up the overall execution time.

SPIRO Google Plus