Can a @Target-less (runtime-retained) annotation be applied on a type parameter declaration?

Laird Nelson ljnelson at gmail.com
Tue Mar 7 23:52:47 UTC 2023


Using Java 19:

@Retention(RetentionPolicy.RUNTIME)
public @interface A {}

public class B<@A C> {}

Why does javac say that A is "not applicable in this type context"?  (I
understand that things have changed here in various versions of the JLS and
related @Target javadocs over the years so I'm probably misreading
something.)

(Originally asked on StackOverflow with more detail:
https://stackoverflow.com/questions/75667924/a-target-less-annotation-cannot-be-applied-to-a-type-parameter-declaration-in-j

Thanks,
Laird
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/compiler-dev/attachments/20230307/de8a3937/attachment.htm>


More information about the compiler-dev mailing list