The OpenJDK project has merged JEP 401, introducing Value Objects as a preview feature, into the master branch. This marks a significant milestone in the long-running effort to add value types to the Java language, promising reduced memory overhead and improved cache performance for certain data structures.
Understanding Value Objects in Java
Value Objects are a new kind of data type designed to behave like values rather than objects. Unlike regular Java objects, they have no identity, so the JVM can compare them by their fields rather than by memory address. They are inherently immutable, and their storage can be inlined directly into the heap or stack, reducing the overhead of reference indirection.
This design allows the JVM to treat value objects similarly to primitive types in hot paths, potentially eliminating object headers and reducing garbage collection pressure. Developers familiar with java.lang.Long or java.lang.Integer will find a similar performance profile, but with the flexibility of defining custom types.
Preview Status and Developer Testing
As a preview feature, JEP 401 is subject to change based on community feedback. Developers can enable it in JDK 24 or later using the --enable-preview flag. The OpenJDK team encourages early testing in non-production environments to uncover edge cases and usability issues. The preview period also allows the community to experiment with the new value keyword and the IdentityObject and ValueObject marker interfaces.
This is not the first preview for value types. Previous iterations appeared in Project Valhalla incubator builds, but the merge to master signals a higher confidence in the design. Developers, however, should expect adjustments before the feature becomes stable and permanent.
Why This Matters
The introduction of Value Objects has the potential to reshape how Java developers model data. For applications that handle large volumes of small data objects, such as financial systems, gaming engines, or data processing pipelines, the performance gains from reduced memory footprint and lower GC overhead could be substantial. Framework authors, particularly those working on ORMs and serialization libraries, will need to adapt their code to leverage value objects efficiently.
Beyond raw performance, this feature aligns Java with trends in modern language design, where value types are increasingly common. Rust, C# and Kotlin all offer value-type semantics, and Java's adoption closes a long-standing gap. The success of this feature could accelerate the adoption of Project Valhalla's broader vision, including primitive specialisation and inline types.
For the broader Java ecosystem, Value Objects represent a stepping stone toward a more efficient and expressive type system. Developers who invest time in understanding and testing the preview now will be better prepared to adopt the final feature when it ships.



