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

Jan Lahoda jan.lahoda at oracle.com
Thu Jul 9 16:25:57 UTC 2020


Looks good to me. A minor nit might be to move the JCVariableDecl 
recordField into the then section of the subsequent if (so that it is 
not computed unless necessary).

Jan

On 09. 07. 20 4:31, Vicente Romero wrote:
> Hi,
> 
> 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.
> 
> Thanks,
> Vicente
> 
> [1] https://bugs.openjdk.java.net/browse/JDK-8242529
> [2] http://cr.openjdk.java.net/~vromero/8242529/webrev.00/


More information about the compiler-dev mailing list