Java - How do I create an annotation type that is only applicable in type contexts? (PURE type annotation)
问题 To create a type annotation that is applicable in type contexts, there is no way other than meta-annotating the annotation type with @Target(ElementType.TYPE_USE) . However, this annotation also becomes applicable in declaration contexts due to the bad decision of the Java designers. According to the Java SE documentation, it reads: The constant TYPE_USE corresponds to the type contexts in JLS 4.11, as well as to two declaration contexts: type declarations (including annotation type