Saturday, November 29, 2025

JVM Architecture in Java

 The Java Virtual Machine (JVM) architecture is a core component of the Java Runtime Environment (JRE) and enables Java's "Write Once, Run Anywhere" capability. It provides a runtime environment for executing Java bytecode. 

The JVM architecture consists of several key components:
1. Class Loader Subsystem:
  • Responsible for loading, linking, and initializing Java classes.
  • Loading: Finds and loads the class file (.class) into memory.
  • Linking: Verifies the loaded bytecode, prepares static fields with default values, and resolves symbolic references.
  • Initialization: Executes class static initializers and assigns actual values to static variables.
  • It has a hierarchical structure with Bootstrap, Extension, and Application Class Loaders.
2. Runtime Data Areas (Memory Areas):
  • These are the memory areas used by the JVM during program execution.
  • Method Area: Stores class-level data like class structure, method data, constructor information, and static variables. It is shared among all threads.
  • Heap Area: Stores all objects and instance variables. It is also shared among all threads and is subject to garbage collection.
  • Stack Area: Each thread has its own private JVM stack, which stores method calls (stack frames) and local variables.
  • PC Registers: Each thread has its own Program Counter (PC) register, which stores the address of the next instruction to be executed.
  • Native Method Stack: Stores information about native methods (methods written in languages other than Java).
3. Execution Engine:
  • Responsible for executing the bytecode loaded by the Class Loader.
  • Interpreter: Reads and executes bytecode instruction by instruction.
  • Just-In-Time (JIT) Compiler: Identifies "hot" code (frequently executed sections) and compiles it into native machine code for faster execution.
  • Garbage Collector: Automatically reclaims memory occupied by unused objects in the Heap.
4. Java Native Interface (JNI):
  • Provides an interface for Java code to interact with native applications and libraries written in other languages (like C/C++).
5. Native Method Libraries:
  • These are the native libraries (e.g., .dll on Windows, .so on Linux) that contain the implementations of native methods called through JNI.

Reference  from Google  AI Review

No comments:

Post a Comment

Some interesting things to explore more

 Here  some  some  things  to  study  more ,     How Google Search works               https://developers.google.com/search/docs/fundamental...