The last miles

Dan Smith daniel.smith at oracle.com
Tue Aug 22 20:27:19 UTC 2023


On Aug 22, 2023, at 12:29 PM, John Rose <john.r.rose at oracle.com> wrote:


If abstract classes which are super
classes of value classes can now have fields, does that encourage
developers to adopt patterns which rely on pointer polymorphism and
forfeit flattening?  The concern here is less about can we do this but more
about should we do it?

I think we should consider this feature for a future release of Valhalla.
There is nothing special about this feature that would make it defeat
the VM in its usual job of optimizing whatever the user throws at it.
As usual inlining will probably be sufficient, and if not there are
other tricks we can play.

I'll add that I think the moral hazard of writing polymorphic code is equally present in interfaces (default methods) and fieldless abstract classes (concrete methods that don't mention fields). I'm not seeing that dynamic significantly changing in the presence of fields.

Does this hold together with our story on implicit constructors (generate
both an implicit_creation attribute and a method in the class)?

Probably, but that’s a question Dan can answer more surely than me.

Yeah, the "I allow implicit instance creation" metadata is, at the class file level, orthogonal to constructors. The flag enables the VM to create all-zeros instances without running any code. The constructor bodies determine what happens when a constructor is explicitly invoked.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/valhalla-spec-observers/attachments/20230822/821222c2/attachment.htm>


More information about the valhalla-spec-observers mailing list