[lworld] RFR: 8280382: [lworld] JCWithField AST node support should evolve to work with value classes

Srikanth Adayapalam sadayapalam at openjdk.java.net
Fri Jan 28 05:06:40 UTC 2022


On Thu, 27 Jan 2022 19:24:47 GMT, Aggelos Biboudis <duke at openjdk.java.net> wrote:

> This PR ports basic `withField` tests from lworld-values to value-objects and extending some areas of code to support `withField` within value classes.
> 
> Nitpicking and a note: one of the error messages is now `compiler.err.primitive.or.value.class.instance.field.expected.here`. Would you propose to disambiguate further depending whether we are inside a `primitive` or a `value` class?

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java line 333:

> 331:                 */
> 332:                 if (env.info.inWithField && v.getKind() == ElementKind.FIELD && (v.flags() & STATIC) == 0 && (v.owner.type.isPrimitiveClass() || v.owner.type.isValueClass())) {
> 333:                     if (env.enclClass.sym.outermostClass() == v.owner.outermostClass())

I suggest we fix all places where a check is being made for isPrimitiveClass() || isValueClass() to just check for isValueClass(). Every primitive class is also a value class so this check is redundant and also is not in alignment with other places where only isValueClass() check is being made. Thirdly and most importantly, we want to reach a state in the codebase where every check of isPrimitiveClass() is essential to triggering behavior that is unique to B3 classes. Any code controlled by isPrimitiveClass() must be specific for B3 classes. This will significantly improve code readability.

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

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



More information about the valhalla-dev mailing list