JVM in Java

The role of a virtual machine depends on memory management, data types, and instructions. These components are structured in abstract inner architecture for the abstract Java virtual machine.

Every Java virtual machine has a class loader (is a mechanism for loading classes and interfaces) given qualified names. JVM has a technique that is responsible for executing the instructions in the methods of loaded classes called execution engine. When the Java virtual machine loads a type, it uses a loader class to locate the particular class file. The class loaders read the class files a stream of binary data and pass to the java virtual machine. The java virtual machine extracts information about the type from the binary data and stores the information in method area. The size of the method area need not be fixed. When the Java programs runs then the virtual machine can expand the method area to fit the application requirements.

When a Java virtual machine runs a program, it needs memory space to store byte codes and other information it extracts from loaded class files, objects of the program instantiates, methods signature, return values, local variables, and results of computations. Java virtual machine manages the memory management and needs to execute a program into runtime areas. The abstract natures of the specification of runtime areas make it easier to implement the Java virtual machine on a wide range of devices. Every instance of Java virtual machine has method area and heap. These areas are shared by all threads running inside the virtual machine. When it loads a class then it parses information about a type from the binary data of class file. It places such information to the method. So, as the program runs, the jvm places all objects instantiates onto the heap. Whenever a class instance or array is created in a running application, the memory required for the new object is allocated from a single heap. As each new thread now comes into existence, it gets its own program counter register and Java stack

The Java stack is composed of stack frames.

The stack frame has three parts:

 

Local variables.

Operand stacks.

Frame data.

 

The sizes of the local variables and operand stack are based on the requirement of each method. These sizes are work at compile time and included in the class file data for every method. The JVM performs only two operations directly on Java Stacks: pushes and pops frames.

When the JVM come across instructions that operate on stored data stack frame,it performs those operations on the current stack frame. When a thread passes with method, the JVM creates a new frame onto the threads of Java stack. This new frame becomes the current frame. So the method executes, it uses the frame to local variables, store parameters, computations.

The Java virtual machine computes by performing operations with selected data types. The data types and operations are strictly defined by the Java virtual machine specification. The data types are followed under the group of primitive and reference data type. Primitive types store primitive values, and reference type store reference values. Reference values refer to objects.

Leave a Reply

Your email address will not be published. Required fields are marked *