Slight inconsistency between state of valhalla and the value objects draft JEP

Stig Rohde Døssing stigdoessing at gmail.com
Thu Dec 23 22:13:03 UTC 2021


Hi,

The updated state of valhalla at
https://openjdk.java.net/projects/valhalla/design-notes/state-of-valhalla/03-vm-model#flattening-and-representation
says that final fields containing value objects can regularly be flattened,
even when using the L descriptor. It also says that value objects might not
be flattenable if referenced through a non-sealed interface, which I
understand to mean that if it is referenced through a sealed interface, we
might not have to pay the polymorphism tax, and might still be able to
flatten?

The draft JEP at https://openjdk.java.net/jeps/8277163 is more
conservative, and says that value objects in fields and value objects
viewed as an instance of a supertype will be heap allocated.

Is the JEP just being a bit too conservative? It sounds great if flattening
is still possible as long as the fields are final or the superinterface is
sealed. I think this would make a big difference for Scala's Option type,
which is a sealed interface.

Completely unrelated, I noticed in
https://openjdk.java.net/projects/valhalla/design-notes/state-of-valhalla/02-object-model#identity-sensitive-operations,
the System::IdentitiyHashCode section references primitive objects, which
are introduced later in the document. I'm guessing it is supposed to
reference value objects instead?



More information about the valhalla-dev mailing list