JEP 401, titled "Value Objects (Preview)", has been incorporated into JDK 28. This update introduces a new type of class instance known as a value object. These objects are characterized by being identity-free and having all their fields implicitly declared as final. The introduction of value objects is a significant step towards enabling flatter and potentially allocation-free representations within the JVM.
A key change brought by JEP 401 is the redefinition of the '==' operator's behavior for value objects. For traditional identity objects, '==' continues to compare references. However, for value objects, '==' now evaluates to true if both operands are instances of the same class and possess identical field values. Reference-typed fields within value objects are compared recursively using '=='. This does not replace the use of 'equals()' for object comparison.
Developers will encounter a new 'value' modifier for declaring value classes, such as 'value class Point { ... }' or 'value record Color(...) { ... }'. These classes come with stricter construction rules, requiring all instance fields to be assigned before the instance is fully constructed. Additionally, instance methods of a value class cannot be synchronized. The preview feature is disabled by default and must be explicitly enabled at both compile time and runtime using '--enable-preview'.
With preview features enabled, several existing value-based JDK classes, including primitive wrappers and 'LocalDate', will adopt the new value class semantics. When the preview is disabled, these classes revert to their identity-object forms, maintaining compatibility with JDK 27 behavior. This initiative stems from years of discussion within the OpenJDK valhalla-dev mailing list, indicating a long-term strategic direction for Java's object model.
✨ This summary was generated by AI from the outlets' reporting listed below. It is not independently verified and may contain errors — check the original sources. How BrevFeed works →
One email each morning: the day's tech stories, clustered across outlets and summarized. No account needed.
One email a day. Unsubscribe in one click, any time.
Spend a few minutes, get the whole day. Every topic's top stories in one hands-free rundown — listen, watch, or read the transcript.
▶ Play today's briefNew every morning, and the back catalogue is archived by date.
JEP 401, "Value Objects (Preview)", has been integrated into JDK 28, introducing identity-free class instances with final fields and altering the behavior of the '==' operator for these new value objects. This change allows for flatter, allocation-free JVM representations and requires developers to use a new 'value' modifier and adhere to stricter construction rules.