The JVM
In the JVM specification, the behavior of a virtual machine instance is described in terms of subsystems, memory areas, data types and instructions.
These components describe an abstract inner architecture for the abstract Java virtual machine. These are not contributing to the implementations of the JVM. These are like abstracts, the external behavior of implementations. The specification defines the required behavior of any Java virtual machine implementation in terms of these abstract components and their interactions.
Below block diagram of the JVM includes the major subsystems and memory areas.
- Java virtual machine has a class loader (used for loading classes, interfaces and gives fully qualified names).
- Java virtual machine also has an execution engine: a mechanism responsible for executing the instructions contained in the methods of loaded classes.
When a Java virtual machine runs a program, it needs memory to store many things, including byte codes and other information it extracts from class files,
- Objects the program instantiates,
- parameters to methods,
- return values,
- local variables and
- intermediate results during computations.
Some run time data areas are shared among all of an application's threads and others are separate to threads. Each instance of the Java virtual machine has one method area and one heap. These areas are shared by all threads running inside the virtual machine. When the virtual machine loads a class file, it parses information about a type in the loaded class file. It places this type information into the method area. As the program runs, the virtual machine places all objects the program instantiates onto the heap.
![]() |
As each new thread comes into existence, it gets its own register and Java stack. If the thread is executing a Java method (not a native method), the value of the pc register indicates the next instruction to execute. A thread's Java stack stores the state of Java method invocations for the thread. What and all a method invocation includes? - its local variables, the parameters with which it was invoked, its return data type and value and intermediate calculation results if any. The state of native method invocations is stored in native method stacks, as well as possibly in registers.
The Java stack is composed of stack frames (or frames). A stack frame contains the state of a method invocation. When a thread invokes a method, the JVM pushes a new frame onto that thread's stack. When the method completes, the virtual machine pops and deletes the frame for that method.
Please note : No thread can access the pc register or Java stack of another thread.
Run-time data areas exclusive to each thread.
Above diagram shows virtual machine, in which two threads are executing. At the instant of the snapshot, threads one and two are executing Java methods.
If you notice well here, the stacks are shown growing downwards. The "top" of each stack is shown at the bottom of the figure. Stack frames for currently executing methods are at bottom. The next frame that to be executed is stored in the PC-Registers specific to each thread.