Core Components
The OpenJDK architecture consists of several key subsystems that work together to execute Java applications:Runtime System
Thread management, class loading, and execution control
Memory Management
Heap allocation, garbage collection, and metaspace
Execution Engine
Interpreter and JIT compilation system
Module System
JPMS implementation and module resolution
Thread Hierarchy
The HotSpot VM implements a sophisticated thread hierarchy defined insrc/hotspot/share/runtime/thread.hpp:
All Thread subclasses must be either JavaThread or NonJavaThread. This binary classification simplifies thread identification and management throughout the VM.
Thread Execution Sequence
Each thread follows a standardized execution sequence:- Native Entry - Platform-specific entry point (
thread_native_entry) - Stack Initialization - Stack setup and OS-level initialization
- Handshake - Synchronization with creating thread
- Common Entry - Shared entry point (
call_run()) - Pre-run - Virtual per-thread-type initialization
- Run - Main thread logic (virtual method)
- Post-run - Virtual per-thread-type tear-down
- OS Tear-down - Minimal cleanup and final logging
Heap Architecture
OpenJDK supports multiple garbage collector implementations, all inheriting from theCollectedHeap base class defined in src/hotspot/share/gc/shared/collectedHeap.hpp:
- Heap Hierarchy
- Key Operations
Class Loading and Metadata
The classfile subsystem (src/hotspot/share/classfile/) handles:
- Class Loading - Parsing and verification of class files
- Module System - JPMS implementation via
ModuleEntryand related classes - System Dictionary - Class lookup and resolution
- Class Linking - Symbol resolution and verification
Object Representation
Classes are represented internally using the Klass hierarchy (src/hotspot/share/oops/):
Klass- Base metadata classInstanceKlass- Represents Java classesArrayKlass- Base for array typesTypeArrayKlass- Primitive arraysObjArrayKlass- Object arrays
- Specialized variants:
InstanceMirrorKlass,InstanceRefKlass,InstanceStackChunkKlass
The “oops” directory name stands for “ordinary object pointers” and contains the fundamental object and metadata representations used throughout HotSpot.
Interpreter System
HotSpot includes two interpreter implementations (src/hotspot/share/interpreter/):
Template Interpreter
The primary interpreter that generates platform-specific assembly code at VM startup. Key components:templateTable- Bytecode interpretation logictemplateInterpreter- Runtime frame managementbytecodes- Bytecode definitions and utilities
Zero Interpreter
A portable C++ fallback interpreter for platforms without template interpreter support:bytecodeInterpreter- C++ bytecode interpretationzeroInterpreter- Frame management
Compiler Integration
The VM integrates multiple compilation tiers through theAbstractCompiler interface:
- C1 Compiler - Client compiler for fast compilation
- C2 Compiler - Server compiler for peak performance
- JVMCI - JVM Compiler Interface for Graal and other compilers
CompilerThread instances that process methods from a compilation queue.
Memory Regions
The VM manages several distinct memory regions:| Region | Purpose | Location |
|---|---|---|
| Heap | Java objects | Managed by GC |
| Metaspace | Class metadata | Native memory |
| Code Cache | JIT compiled code | Native memory |
| Thread Stacks | Execution frames | Per-thread native memory |
| Native Memory | VM internals | OS allocation |
Services and Monitoring
Thesrc/hotspot/share/services/ subsystem provides:
- JMX Integration - Management beans and monitoring
- Memory Pools - Per-region memory tracking
- GC Managers - Garbage collection monitoring
- Thread Monitoring - CPU time and contention tracking
Platform Abstraction
Platform-specific code is isolated in OS-specific directories:src/hotspot/os/linux/- Linux implementationsrc/hotspot/os/windows/- Windows implementationsrc/hotspot/os/bsd/- BSD variantssrc/hotspot/cpu/x86/- x86/x64 architecturesrc/hotspot/cpu/aarch64/- ARM 64-bit
os subsystem provides abstractions for threading, memory management, and synchronization primitives.
Next Steps
HotSpot VM
Deep dive into HotSpot internals
Garbage Collection
GC algorithms and implementations
JIT Compilation
C1, C2, and Graal compilers
Module System
JPMS architecture and implementation