← All stories
● Covered by 1 source · 1 reportMedium impact1 neutral

JEP 401 Introduces Value Objects and Redefines '==' for Them in JDK 28 Preview

🔄 Updated 1d ago
New to BrevFeed? We gather this story from every outlet covering it into one summary — ranked by real-world impact, not just the latest headline — so you never miss what matters. What is BrevFeed? →

Key points

  • JEP 401 introduces 'value' classes to JDK 28.
  • Value objects are identity-free with implicitly final fields.
  • '==' operator compares field values for value objects.
  • Preview features are disabled by default and require explicit enabling.

Introduction of Value Objects

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.

Changes to '==' Operator Behavior

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.

Developer Implications and Syntax

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'.

Impact on JDK Classes and Future Development

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 →

The daily brief

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.

Today's brief

Spend a few minutes, get the whole day. Every topic's top stories in one hands-free rundown — listen, watch, or read the transcript.

~7 min · 6 stories · Aug 15

▶ Play today's brief Listen on Spotify

New every morning, and the back catalogue is archived by date.

Reporting from

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.