RFR: JDK15-8242529: javac defines type annotations incorrectly for record members (constructor and property accessor)

Vicente Romero vicente.romero at oracle.com
Thu Jul 9 02:31:26 UTC 2020


Please review fix for [1] at [2]. Current record implementation is not 
forward nested type annotations to generated members like in:

record R(@RegularAnnotation @TypeAnnotation Callable<@TypeAnnotation ?> foo) {}

This patch is fixing one issue that show up in two different generated 
record members:
     - the accessor corresponding to the record component
     - the corresponding parameter in the canonical constructor

The issue is that the current implementation is not able to correctly 
generate the annotated types for these components when such an annotated 
type has "inner" type annotations like it is the case of `foo` in the 
example which has `TypeAnnotation` applied to the wildcard. In the case 
of the corresponding parameter in the canonical constructor the 
annotated type was generated correctly but the class file reflected the 
internal type annotation as applied to a field not to a method 
parameter. In the case of the accessor the inner annotation was not 
there at all. The patch is making a copy of the expression defining the 
type of the record component and placing it that the right place for 
both generated members.


[1] https://bugs.openjdk.java.net/browse/JDK-8242529
[2] http://cr.openjdk.java.net/~vromero/8242529/webrev.00/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20200708/f198e430/attachment.htm>

More information about the compiler-dev mailing list