r/java • u/nlisker • Jul 14 '26
New candidate JEP: 401: Value Objects (Preview)
https://mail.openjdk.org/archives/list/valhalla-dev@openjdk.org/thread/IUNJJ3WP3X3XHP3QZTXXSSCPKFDNTK3W/
85
Upvotes
View all comments
Show parent comment
6
u/SirYwell Jul 15 '26
The JEP answers all of these questions and so much more, but I'll try to summarize the relevant parts:
==for comparisons. Currently, for reference types, that means identity comparison. Value objects do not have an identity, so==needs new semantics for them. Note that the semantics might not be what you want, especially with floating point numbers involved. You can read more about it in the Comparing value objects section.I highly suggest reading the JEP, it provides so much interesting details.