Class Loader
Also known as:
ClassLoader
Class Loading
Class Loader Subsystem
Definition
A class loader is the part of the JVM that finds .class files and brings their bytecode into memory. It works in three phases: loading (read the class file), linking (verify the bytecode, prepare static fields, resolve references), and initialization (run static blocks). Classes load lazily on first use, and loaders follow a parent-first delegation model from the bootstrap loader down to the application loader, which prevents untrusted code from shadowing core Java classes.
Popular reads
View All
Cursor Skills: How to Create and Use Agent Skills
Jun 23, 2026
Payment System Design: Ledger, Idempotency, and Settlement
Jul 18, 2026
X Algorithm Explained: How the Open Source Recommendation System Works
Jan 22, 2026
Complete Guide to Graph Data Structure: BFS, DFS, Adjacency List vs Matrix
Jan 20, 2026
The Complete HTMX Guide: From Zero to Production
Dec 22, 2025
Transactional Outbox Pattern: Never Lose an Event Again
Apr 07, 2026
Key Takeaways
- Class loading has three phases: loading, linking (verify, prepare, resolve), and initialization.
- Classes are loaded lazily, the first time they are actually referenced, not all at once at startup.
- The parent-first delegation model (bootstrap, platform, application) is a security feature that stops fake core classes.
- Each loaded class gets one
java.lang.Classobject on the heap, which is the handle reflection uses.
How It Works
- A loader is asked for a class and first delegates the request to its parent loader.
- If no parent can supply it, the loader reads the
.classbytes and stores the metadata in the method area. - Linking verifies the bytecode, allocates static fields with default values, and resolves symbolic references.
- Initialization runs static initializers exactly once per class, guaranteed thread-safe by the JVM.
Where It Is Used
- Application servers and plugin systems use custom class loaders to isolate modules from each other.
- Hot-reload and live-restart tools swap class loaders to pick up recompiled classes without a full restart.
- A ClassNotFoundException or NoClassDefFoundError almost always points to a class loading or classpath problem.