JEP 401: Value Classes and Objects has been integrated into the main OpenJDK repository, targeting JDK 28, via a pull request adding over 197,000 lines of code across 1,816 files, according to JVM Weekly. The change introduces value classes, a long-planned piece of Project Valhalla intended to eliminate pointer indirection and object header overhead for high-performance workloads.
How Value Classes Change Java's Memory Model
Historically, Java treated every non-primitive type as a heap reference. An array of objects meant an array of pointers, scattering data across memory and causing frequent CPU cache misses. The JIT compiler's escape analysis can sometimes optimize this away, but the mechanism is fragile and often fails once objects cross method boundaries or land in arrays.
Value classes address this by removing object identity. Declared with the value modifier, they require final fields, disallow synchronization, and let the JVM flatten data structures into dense, contiguous memory blocks.
Key Details of JEP 401
- Targeting JDK 28: Integrated into main OpenJDK as a preview feature, disabled by default.
- Unified descriptor model: Value objects share the JVM's 'L' descriptor carrier model with standard references, avoiding duplicated type infrastructure.
- Identity-free semantics: Value objects lack identity headers, simplifying JVM memory layout optimizations.
- Simplified model: Replaces earlier dual-projection designs (
Point.val/Point.ref) with a single value class concept, per the source's account of the JEP's design history.
Performance Rationale
Modern CPUs run roughly two orders of magnitude faster than main memory access, a gap that didn't exist when Java's object model was designed in the 1990s. High-performance domains like analytics, image processing, and numerical computing have often worked around this by manually packing raw bytes rather than relying on Java's object model. Value classes let developers write domain types such as points, vectors, or complex numbers that the JVM can flatten into arrays without indirection.
Caveats
As a preview feature, JEP 401 requires developers to explicitly enable preview flags to test it in JDK 28. Related work — including specialized generics and null-restricted value types — remains split into separate, future JEPs and is not part of this delivery.
Why It Matters
Project Valhalla has been a multi-year effort to close the gap between Java's reference-based object model and how modern CPUs actually access memory. Landing JEP 401 in the main OpenJDK repository as a JDK 28 preview is a concrete step toward that goal, though full generics support and non-nullable value types are still to come.