Class Loading Phases: Load, Link, Initialize
Walk through loading, verification, preparation, resolution, and initialization of classes.
The Class Loading Lifecycle
A Java class goes through three phases before it can be used: Loading (find and read the bytecode), Linking (verify, prepare, resolve), and Initialization (run static initializers).
Phase 1: Loading
The ClassLoader reads the .class file (from filesystem, JAR, network, or generated bytecode) and creates a Class<?> object in the heap representing it.
// Trigger loading explicitly:
Class<?> c = Class.forName("com.example.MyService");
// The JVM delegates to the appropriate ClassLoader to find and load MyService.classAll lessons in this course
- Class Loading Phases: Load, Link, Initialize
- ClassLoader Hierarchy and Custom Loaders
- Inspecting Bytecode with javap
- JIT Compilation and Tiered Compilation