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

Laird Nelson ljnelson at
Thu Feb 16 21:31:06 UTC 2023

Another TYPE_USE question. Consider:

@Target({ ElementType.TYPE_USE })
@interface A {}

@A class B{}

I am surprised to see @A in the returned array from
B.class.getAnnotations() since it is not an element annotation.

Furthermore, I do not see the string "RuntimeVisibleTypeAnnotations" in the
class file for B (which is why I'm writing to the compiler-dev list). I am
no VM/bytecode person but I would expect to see that if a runtime-visible
type use annotation is being recorded, yes? Although I do not see a place
in the target_info structure that would to my naive eyes be suitable for
this particular usage.

Is @A's usage here recorded in the wrong place as the wrong sort of thing?
This has a whiff of to it but I
wanted to confirm.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the compiler-dev mailing list