Oredering of fields in inline types and records

Brian Goetz brian.goetz at oracle.com
Fri Mar 6 16:59:21 UTC 2020

Yes and yes.  The VM still has this flexibility.  

Because the protocol (construction and deconstruction) of records appeals to a canonical ordering of components, we reify this ordering in the Record attribute, and expose it via reflection.  But that is the only place the components are guaranteed to appear in the order they did in the source.

> On Mar 6, 2020, at 4:53 PM, Stephen Colebourne <scolebourne at joda.org> wrote:
> In a normal class with multiple fields, my understanding is that the
> JVM is free to layout the fields in memory however it wishes,
> potentially to make them better align with the underlying
> architecture. ie. it is not constrained to lay them out in source code
> order.
> Does the JVM still have this flexibility with records?
> Will the JVM still have this flexibility with inline types?
> (I don't remember seeing this discussed/answered before, but I could be wrong!)
> thanks
> Stephen

More information about the valhalla-dev mailing list