[lworld] RFR: 8244231: [lworld] Add support for ref-default and val-default inline classes.

Srikanth Adayapalam sadayapalam at openjdk.java.net
Thu Jul 22 07:02:03 UTC 2021


On Wed, 21 Jul 2021 12:09:11 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java line 326:
>> 
>>> 324:                 */
>>> 325:                 if (env.info.inWithField && v.getKind() == ElementKind.FIELD && (v.flags() & STATIC) == 0 && v.owner.isPrimitiveClass()) {
>>> 326:                     if (env.enclClass.sym.outermostClass() == v.owner.outermostClass())
>> 
>> This is an example of a code change you will see recur several times: Earlier when we had only value default primitive classes to check if a field is a field of a primitive class it was alright to ask
>> 
>> types.isPrimitiveClass(v.owner.type)
>> 
>> With ref-default classes entering the picture if v.owner is a ref-default primitive class then v.owner.type will not
>> answer true for the above check. (For a ref-default primitive class Optional.val, Optional.type is 'L' type not Q type) and we need to check
>> 
>> owner.isPrimitiveClass()
>> 
>> which will answer true for both val-default and ref-default primitive classes.
>
> Yes, but again, leaving a method in `Types` called `isPrimitiveClass` which takes a type and return false when the type is derived from a primitive class seems suboptimal. See my comment on `Type::isPrimitiveClass`. I think what you want there is probably `isPrimitiveType`. or `isValueType` or something like that - stay away from `Class`.

Fair points. 

Since we already have com.sun.tools.javac.code.Type#isPrimitive it is useful to retain to "Class" somewhere in the new APIs name although perhaps not in the present form of Type#isPrimitiveClass()

Perhaps the old method should be renamed to isBasicPrimitive() and the new one should be isPrimitiveClassType()

I will carry over these comments to JDK-8268734 (Various internal Type/Symbol APIs need rationalization/adjustment)

-------------

PR: https://git.openjdk.java.net/valhalla/pull/482


More information about the valhalla-dev mailing list