Early Access Release

The latest early access release of Valhalla features is published at https://jdk.java.net/valhalla/.

This release is a modified build of JDK 26 that fully supports JEP 401: Value Classes and Objects (Preview). We encourage users to experiment with value objects and explore their performance implications. We welcome user feedback at valhalla-dev@openjdk.org as we work toward a preview release in an upcoming JDK.

Functionality, language syntax, and class file formats are subject to change. Some supplementary tools and APIs do not fully support the new features. The goal of each EA release is to solicit feedback and establish a milestone along the path to an official preview feature.

Value Classes and Objects

See the Value Classes and Objects JEP for an in-depth overview of the new features. Detailed language and VM changes are available as well.

When the --enable-preview command-line flag is used, Java programs are allowed to use value classes and records, which have only final fields and lack object identity. At run time, the == operator compares value class instances according to their field values, without regard to when or where they were created. Other identity-sensitive operations have been adjusted to appropriately work with objects that lack identity.

Developers can save memory and improve performance by using value objects for immutable data. Because programs cannot tell the difference between two value objects with identical field values (not even with ==), the Java Virtual Machine is able to change how a value object is laid out in memory without affecting the program; for example, its fields could be stored on the stack rather than the heap.

By enabling preview features, developers also get value-class versions of java.lang.Integer, java.time.LocalDate, java.util.Optional, and a handful of other classes in the standard libraries. Developers are encouraged to test their code against these modified libraries, along with declaring their own value classes.

Please provide any feedback to valhalla-dev@openjdk.org.

Notes