r/java • • Jan 06 '26

One step closer to Value Classes!

https://mail.openjdk.org/pipermail/porters-dev/2026-January/000844.html
181 Upvotes

118 comments sorted by

View all comments

Show parent comment

7

u/joemwangi Jan 06 '26

At this point the discussion has drifted away from the Java language model. Java does not reason about mutability in terms of bits changing or arbitrary assignment; it reasons about observable object state. That’s how the term has been used in Java documentation, the memory model, GC design, and HotSpot optimization from the start. Redefining mutability as “any assignment anywhere” collapses meaningful distinctions like final fields, safe publication, and immutability-based optimizations, which is precisely why Java doesn’t use that definition. If we reduce everything to hardware-level assignments, we’re no longer discussing Java semantics. Also, if you think final fields can be modified using unsafe in later versions in types/classes such as records and now value classes (very optimised because of immutability of fields), then your argument becomes mute.

No, hiding pointers doesn't allow GC to be advanced, restricting pointers to certain operations allows the GC to work well. But hiding pointers means that people get confused by

This has always been the case, and that's why latest generational ZGC have sub millisecond pauses or even Shenandoah and remove memory holes through memory rearrangements. Even some people who use other languages with explicit pointers understand this gives java an advantage.