java language specification 翻译 9.6 Annotation Types 注解类型
来源:互联网 发布:医药公司进销存软件 编辑:程序博客网 时间:2024/05/21 08:04
9.6 注解类型
一个注解类型的声明指定一个新的注解类型,一个特殊的接口类型。为了区别一个注解声明和一个一般的接口声明,在关键词interface
前加一个at-符号(@)。
AnnotationTypeDeclaration:
{InterfaceModifier} @ interface Identifier AnnotationTypeBody注解类型声明:
{接口修饰符} @ interface 标识符 声明类型主体注意at-符号(@)和关键词 interface 是不同的标识符。可以在它们中间加一个空格,但是并不建议这么做。
在注解类型声明中,注解修饰符的规则在9.7.4和9.7.5节中定义。
在注解类型声明中,Identifier 是注解类型的名字。
如果注解类型和任何它的内部(enclosing)的类和接口有相同的名字,就会产生一个编译时错误。
每个注解类型的直接父接口是 java.lang.annotation.Annotation
。
根据注解类型声明语法,一个注解类型声明不能是泛类,而且不能有
extends
。因为一个注解类型不能显示声明一个父类或父接口,因此一个声明类型的子类或子接口不能是声明类型。同理,
java.lang.annotation.Annotation
不是声明类型。
一个注解类型从 java.lang.annotation.Annotation
中继承了几个成员,包括隐式的从Object
中继承的方法,然而这些方法没有定义声明类型的成员(9.6.1节)。
因为这些方法没有定义注解类型的成员,在用注解类型是用它们是不合理的(9.7节)。如果没有这条规则,我们就不能保证(elements were of the types representable in annotations, or that accessor methods for them woule be available.)。
除非显示的在此修改,所有使用与普通接口定义的规则也适用于注解的定义。
例如,注解类型和普通的类和接口类型共享相同的命名空间;在定义接口合法的地方,都可以定义注解类型,并且有相同的范围和可访问性。
9.6.1 注解类型要素(Annotation Type Elements)
注解类型的主体可能包含方法们的声明,每一个都是注解类型的要素(element)。一个注解类型没有要素(elements),除非这些显示声明的方法。
AnnoatitonTypeBody:
{{AnnotationTypeMemberDeclaration}}AnnotationTypeMemberDeclaration:
AnnotationTypeElementDeclaration
ConstantDeclaration
ClassDeclaration
InterfaceDeclaration
;AnnotationTypeElementDeclaration:
{AnnotationTypeElementModifier} UnannTypeIdentifier () [Dims] [DefaultValue];AnnotationTypeElementModifier:
(one of)
Annotation public
abstract
- java language specification 翻译 9.6 Annotation Types 注解类型
- java language specification官方地址
- [iOS翻译]《The Swift Programming Language》系列 集合类型(Collection Types)
- 深入理解Java注解类型(@Annotation)
- 深入理解Java注解类型(@Annotation)
- The Java™ Language Specification, Third Edition
- C# Language Specification 5.0 (翻译)第六章 转换
- 【Java】【Annotation】Java Annotation (注解)
- JAVA Annotation 注解
- JAVA 注解(annotation)
- Java Annotation(注解)
- 11.Java注解(Annotation)
- java注解(Annotation)
- java注解Annotation
- java 注解(Annotation)
- Java注解Annotation
- Java Annotation 注解
- JAVA注解 Annotation
- 粒子群算法(PSO)介绍及matlab实现
- CSDN通知信息这是什么鬼
- 数据结构之图的存储表示(邻接矩阵、邻接表和边集数组)
- Vue—params传递值
- jzoj. 3518. 【NOIP2013模拟11.6A组】进化序列(evolve)
- java language specification 翻译 9.6 Annotation Types 注解类型
- webpack对比requirejs
- 机试练习7.11
- Android系统广播大全
- kotlin 学习笔记
- python3实现计算器基本功能
- C语言不匹配转换
- C#命名规则和编码规范
- x86汇编语言(三)