News for hackers. Stuff that matters.
Re:JEP 401: Value Objects (Preview) merged to OpenJDK master by swaranga on Friday July 31, 2026 @08:12AM (#49122123)
I keep forgetting the reasoning for this part of the design - why is the value semantics baked in the declaration site and not at the use site?

Why does the class author have to declare it as a value type? I know this has been rehashed before many times by Brian but I keep forgetting the reasoning.

Re:JEP 401: Value Objects (Preview) merged to OpenJDK master by cogman10 on Friday July 31, 2026 @08:19AM (#49122179)
Call site is tricky because you need safety guarantees about the underlying data for it to be a value type. For example, it needs to be immutable.

If you were to call a function with a site declared value type, the function you call would have to have syntax as well to indicate "this is a value type I'm receiving and not a regular type" so that it doesn't do an illegal operation with the value type.

Re:JEP 401: Value Objects (Preview) merged to OpenJDK master by DarkNova6 on Monday August 03, 2026 @09:23AM (#49155505)
I think it keeps going back to "preserving type invariants". Turning an object into a value can have surprising constraints on the integrity of the type. These include: forced empty constructor (for bulk initialiation in arrays), violation of cross-field invariance (think of a Range-type where "end" value is suddenly smaller than the "start" due to a data race), etc.

Java always had a focus on enabling library authors over empowering call-site users. And I think approach has proven its dividend.