Classfile artifacts to support compilation/reflection
daniel.smith at oracle.com
Mon May 3 22:32:45 UTC 2021
> On May 3, 2021, at 4:21 PM, Brian Goetz <brian.goetz at oracle.com> wrote:
>>> 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.
Ha, I was just looking over this! (See email.)
SotV still has an opt-in. It just describes it as a ACC_ABSTRACT flag on an <init> method, rather than a class attribute or something else. (It also describes some additional requirements, like no instance fields, but I argued in the other email that those requirements are better handled as consistency checks, not separate components to the opt-in.)
More information about the valhalla-spec-observers