Classfile artifacts to support compilation/reflection
brian.goetz at oracle.com
Mon May 3 22:21:41 UTC 2021
>> 2. Whether abstract classes are primitive superclass candidates. The static compiler will check this at compilation time when it sees a superclass of a primitive class, but the JVM will want to recheck anyway. There are two sensible ways to handle this in the classfile:
>> - An attribute that says "I am a primitive superclass candidate." The static compiler puts it there, and the JVM checks it.
>> - Infer and tag. If an abstract class is loaded that is not a primitive superclass candidate, the JVM injects IdentityObject as a superinterface of the newly loaded class; when we go to load a primitive subclass, this will fail because primitive classes cannot implement both IdentityObject and PrimitiveObject.
>> Reflection probably doesn't have to reflect whether a class is primitive superclass candidate; it already reflects the things needed to make this determination.
> This one, on the other hand, conveys a core property of a JVM class.
John's notes in the SotV suggests that the JVM is comfortable just
"figuring it out" and not requiring an attribute. So this is the "infer
and tag" option; the VM infers this at runtime. Not clear if there is a
value to having the static compiler capture something that wasn't
explicit in the source and that has to be validated at runtime anyway.
More information about the valhalla-spec-observers