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

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


Another TYPE_USE question. Consider:

@Retention(RetentionPolicy.RUNTIME)
@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 https://bugs.openjdk.org/browse/JDK-8030751 to it but I
wanted to confirm.

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


More information about the compiler-dev mailing list