Is a TYPE_USE annotation stored as such in a class file?

Alex Buckley alex.buckley at oracle.com
Thu Feb 16 23:10:06 UTC 2023


On 2/16/2023 2:54 PM, Laird Nelson wrote:
> How very interesting. So in pragmatic terms, merely looking at an 
> annotation's @Target annotation does not, by itself, tell you all the 
> places it could be used or where it might show up reflectively. I learn 
> something new every day. Thanks for your patience and time.

Looking at an annotation interface `A`'s @Target meta-annotation 
absolutely does tell you all the places that the annotation `@A` may 
appear. Everything about this is checked at compile time -- it has to be 
deterministic.

For example, from `@Target(TYPE_USE)`, you can deduce that `@A` may 
appear on type uses, on class declarations, on interface declarations, 
and on type parameter declarations.

Alex


More information about the compiler-dev mailing list