NOTE

JVM Class Lifecycle

Loading, linking, initialization, use, unloading, and class-loader identity in the JVM.

JavaCreated Updated 1 min readhistorical

This is a historical learning note and may contain outdated or incomplete understanding.

1. Loading

The JVM obtains class binary data and creates runtime class metadata associated with a defining class loader.

2. Linking

Linking includes:

  • verification: check structural/type-safety constraints;
  • preparation: create/prepare static storage and related structures;
  • resolution: turn symbolic references into runtime references, either eagerly or lazily as allowed.

3. Initialization

Initialization executes the class-initialization method generated from static initializers/field initializers when a JVM-defined initialization trigger occurs.

4. Class Identity

A class is identified not only by its binary name but also by its defining class loader. Two loaders can define classes with the same name that are not type-compatible.

5. Unloading

Class unloading generally requires the defining loader and its classes to become unreachable, subject to JVM/collector behavior. Long-lived custom class loaders can therefore retain substantial metadata and objects if application references accidentally keep them alive.

Loading helpful count