RFR: 8303784: no- at Target annotations should be applicable to type parameter declarations [v3]

Joe Darcy darcy at openjdk.org
Thu Mar 23 04:30:43 UTC 2023


On Tue, 21 Mar 2023 18:11:24 GMT, Liam Miller-Cushon <cushon at openjdk.org> wrote:

>> Please consider this fix for https://bugs.openjdk.org/browse/JDK-8303784, which make `@Target`-less annotations applicable to type parameter declarations.
>> 
>> `@Target`-less annotations are applicable to 'all declaration contexts', which includes type parameter declarations.
>
> Liam Miller-Cushon has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Make fix contingent on --release 14
>   
>   based on discussion in CSR.

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java line 3515:

> 3513:         List<Attribute> targets = typeAnnotations.annotationTargets(a.annotationType.type.tsym);
> 3514:         return (targets == null) ?
> 3515:                 (source.compareTo(Source.JDK14) >= 0 && isTypeParameter) :

Usually this kind of test is done using a constant in the Feature enum; I'll let Vicente or other engineer who focuses on javac weigh in on whether or not the direct comparison is acceptable in this case.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/12914#discussion_r1145666707


More information about the compiler-dev mailing list