Fundamentals 7 min read

Unraveling the Java Class‑Object Bootstrap: Which Comes First?

This article explains why the assumption that java.lang.Object is an instance of java.lang.Class is wrong, how Class actually extends Object, and how the JVM resolves the chicken‑egg problem through a bootstrap process that initializes core types before normal execution.

Java High-Performance Architecture
Java High-Performance Architecture
Java High-Performance Architecture
Unraveling the Java Class‑Object Bootstrap: Which Comes First?

In the Java object model, every class is an instance of java.lang.Class, and java.lang.Object is a class, but the claim that Object is also an instance of Class is incorrect.

All classes ultimately inherit from Object, and Class itself is a subclass of Object.

The classic “chicken‑or‑egg” dilemma is solved by a bootstrap process that initializes both core types together.

The JVM allocates memory for the most important core types (e.g., java.lang.Object and java.lang.Class) in a partially‑initialized state, links their references, and then completes their full initialization.

During this bootstrap phase, the HotSpot VM uses the C++ class Universe to track the system state, exposing two key functions:

static bool is_bootstrapping() { return _bootstrapping; }
static bool is_fully_initialized() { return _fully_initialized; }

The function Universe::genesis() creates the core type instances and calls SystemDictionary::initialize(), which in turn invokes SystemDictionary::initialize_preloaded_classes() to create java.lang.Object, java.lang.Class, and other essential classes.

After these classes are loaded, Universe::fixup_mirrors() resolves the circular references between Object and Class, completing the bootstrap.

// Fixup mirrors for classes loaded before java.lang.Class.
Universe::initialize_basic_type_mirrors(CHECK);
Universe::fixup_mirrors(CHECK);

void Universe::fixup_mirrors(TRAPS) {
  // Walk over already allocated permanent objects (mostly classes)
  // and fix their mirrors. The number of objects at this point is very small.
}

Thus, the JVM can have both Object and Class available without a true ordering conflict, similar to bootstrap mechanisms in other runtimes like JavaScript, Python, and Ruby.

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.

JavaJVMReflectionBootstrapClassobject
Java High-Performance Architecture
Written by

Java High-Performance Architecture

Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.

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.