@Documented @Retention(value=RUNTIME) @Target(value=ANNOTATION_TYPE) public @interface Target
java.lang.annotation.ElementType
枚举常量的源代码表示。
如果一个@Target
元注释在注释类型T
是不存在的,然后T
型注释可以写成一个除了类型参数声明的任何声明修饰符。
如果一个@Target
元注释时,编译器将强制使用限制的ElementType
枚举常数表示,与JLS 9.7.4线。
例如,这@Target
元注释表明声明的类型本身是一元注释类型。它只能用于注释类型声明:
“目标(ElementType。annotation_type)接口metaannotationtype {…}
这@Target
元注释表明声明的类型是专为使用在复杂的注释类型声明的成员类型。它不能用来直接注释任何东西:
@目标({ })接口成员类型{…}
这是一个编译时错误一ElementType
常出现超过一次在@Target
注释。例如,下面的@Target
元注释是非法的:
“目标({ elementtype.field,elementtype.method,ElementType。场})公开@接口虚假…}
Modifier and Type | Required Element and Description |
---|---|
ElementType[] |
value
返回一个数组的元素类型,可以应用于注释类型。
|
public abstract ElementType[] value
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.