NOTE

JVM Object Creation

From bytecode allocation through class readiness, heap allocation, zero initialization, object headers, and Java constructor execution.

JavaCreated Updated 1 min readhistorical

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

At a high level, creating an ordinary object involves:

  1. resolving/using the target class and ensuring required class initialization semantics are satisfied;
  2. obtaining storage from the managed heap through the allocator/collector;
  3. establishing the object’s VM metadata/header and default-zeroed instance state;
  4. executing constructor logic, including superclass constructor chaining, according to Java rules;
  5. publishing the resulting reference according to the surrounding program’s synchronization semantics.

The exact allocator path—TLAB, shared allocation, region handling, GC slow path—is a HotSpot/collector implementation detail.

Also distinguish allocation from safe publication. Constructing an object does not by itself make unsynchronized publication to another thread safe.

Loading helpful count