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

Liam Miller-Cushon cushon at google.com
Wed Mar 8 00:06:46 UTC 2023


Hi Laird,

Nice find. I'm curious whether anyone on the list is remembering details
I'm not, but this looks like a bug to me too.

I went ahead and filed: https://bugs.openjdk.org/browse/JDK-8303784

On Tue, Mar 7, 2023 at 3:53 PM Laird Nelson <ljnelson at gmail.com> wrote:

> 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/4eec26d5/attachment-0001.htm>


More information about the compiler-dev mailing list