Fundamentals 5 min read

Unlocking the JVM: Inside Its Core Architecture and Execution Flow

This article explains the Java Virtual Machine's two subsystems—Class Loader and Execution Engine—and its two main components—Runtime Data Area and Native Interface—detailing their functions, internal structures, and the overall execution workflow of Java programs.

Xuanwu Backend Tech Stack
Xuanwu Backend Tech Stack
Xuanwu Backend Tech Stack
Unlocking the JVM: Inside Its Core Architecture and Execution Flow

JVM (Java Virtual Machine) consists of two subsystems and two components: Class loader (class loading subsystem) Execution engine (execution subsystem) Runtime data area (runtime memory region) Native Interface (native integration component)

Class Loader

Loads .class files into the JVM's method area based on the fully qualified class name (e.g., java.lang.Object).

Reads bytecode files from the file system, network, or other sources and converts them into java.lang.Class objects.

Enables dynamic class loading, linking, and initialization.

Execution Engine

Executes bytecode stored in the method area, translating it into machine instructions understood by the OS and hardware.

Main components:

Interpreter : Interprets and executes bytecode instructions line by line.

JIT Compiler : Compiles hot code paths into native code for better performance.

Garbage Collector : Reclaims unused objects and manages heap memory.

Runtime Data Area

Commonly referred to as the JVM memory areas, storing various runtime data.

Key parts: Method Area: Stores class metadata such as constant pool, fields, methods, and constructors.

Heap : Holds object instances and arrays; primary region for garbage collection.

Java Virtual Machine Stack : Per‑thread stack for local variables, operand stack, and method calls.

Native Method Stack : Supports native method (e.g., C/C++) calls.

Program Counter Register : Records the address of the currently executing bytecode instruction.

Native Interface

Interacts with native libraries (e.g., C/C++) allowing Java code to invoke native methods.

Implemented via JNI ( Java Native Interface) for Java‑to‑native communication.

JVM Workflow

1. Compilation Phase : The Java compiler ( javac) converts .java source files into .class bytecode files.

2. Class Loading Phase : The ClassLoader loads bytecode into the method area and creates a java.lang.Class object; includes bootstrap, extension, and application class loaders.

3. Execution Phase : The execution engine reads bytecode from the method area, using the interpreter or JIT compiler to produce machine instructions; native methods are invoked via the Native Interface.

4. Memory Management : The Garbage Collector reclaims heap memory occupied by unreachable objects.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

JavaJVMClass LoaderExecution EngineRuntime Data AreaNative Interface
Xuanwu Backend Tech Stack
Written by

Xuanwu Backend Tech Stack

Primarily covers fundamental Java concepts, mainstream frameworks, deep dives into underlying principles, and JVM internals.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.