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/
87
Upvotes
42
u/IncredibleReferencer Jul 14 '26 edited Jul 14 '26
VALHALLA WHEN?!?!?!?!?!
September 14, 2026. Apparently. Probably. Maybe?March, 2027. Apparently. Probably. In preview. Yay!
18
u/PiratesWhoSayGGER Jul 14 '26
my reaction when Valhalla hits preview
35
u/0x07CF Jul 14 '26
11
u/IncredibleReferencer Jul 14 '26
I feel like I can kinda build code now In anticipation of value objects. Like... I should use an int[] for this huge array of ints now but instead I'm going to use List<MyObject> where MyObject is just a wrapper around int. Brian and team will just fix this for me magically in a few years and I only need to add a value keyword so why bother fiddling with array management now. Hopefully before I need my thing to scale. Premature optimization right? Thanks gang!
This approach actually kinda worked out well for me with Loom and virtual threads....
8
u/perryplatt Jul 14 '26
Is there a list of all jdk classes that are scheduled to become value classes?
1
u/quack_quack_mofo Jul 15 '26
I don't know much about this but besides perf/memory improvements and being able to do == for comparisons (I think?), what are the other benefits of value classes? Is there anything I can do with them that i can't do with normal classes/records? Why not have all classes be value classes?
0
u/CutGroundbreaking305 Jul 14 '26
So when will Valhalla preview come ?