java Annotation原理
来源:互联网 发布:淘宝双十一数据 编辑:程序博客网 时间:2024/06/08 01:20
Annotations are one of the fundamental language changesintroduced in Java SE5. They provide information that you need to fully describe your program, but that cannot be expressed in Java. Thus, annotations allow you tostore extra information about your program in a format that istested and verified by the compiler.
Annotations can be used to generate descriptor files or even new class definitions and help ease the burden of writing"boilerplate" code(样板代码). Using annotations, you can keep this metadata in the Java source code, and have the advantage of cleaner looking code, compile-time type checking and the annotation API to help build processing tools for your annotations. Although a few types of metadata come predefined in Java SE5, in general the kind of annotations you add and what you do with them are entirely up to you.
The syntax of annotations is reasonably simple and consists mainly of the addition of the @ symbol to the language. Java SE5 contains three generalpurpose built-in annotations, defined in java.lang:
•
@Override, to indicate that a method definition is intended to override a method in the base class. This generates a compiler error if you accidentally misspell the method name or give an improper signature.
•
@Deprecated, to produce a compiler warning if this element is used.
•
@SuppressWarnings, to turn off inappropriate compiler warnings. This annotation is allowed but not supported in earlier releases of Java SE5 (it was ignored).
Syntactically, annotations are used in much the same way as modifiers.
Most of the time, you will be defining your own annotations and writing your own processors to deal with them.
Apart from the @ symbol, the definition of @Test is much like that of an empty interface.
(注解相当于一个空的接口,除了系统自带的注解之外,可以自定义注解)
- java Annotation原理
- Java Annotation实现原理
- Java Annotation 原理
- Java中的Annotation(2)----Annotation工作原理
- Java Annotation原理分析(一)
- Java Annotation原理分析(二)
- Java Annotation原理分析(三) --- 内置Annotation介绍
- Java Annotation 注解基础原理简析
- Java Annotation及注解原理简析
- Java注解(Annotation)原理详解
- java基础-注解Annotation原理和用法
- Java注解(Annotation)实现原理
- Java:Annotation(注解)--原理到案例
- Java注解(Annotation)原理详解
- Java注解(Annotation)原理详解
- Java学习之注解Annotation实现原理
- Java注解(Annotation)原理详解
- Java学习之注解Annotation实现原理
- exp_start.sh
- 线程模型
- HDU_1161Eddy's mistakes
- Java初步认识
- 图像处理之去雾——基于图像暗通道的去雾算法
- java Annotation原理
- OCP-1Z0-051 第46题 约束和索引
- nfs简单使用
- HDC,CDC,CWindowDC,CClientDC,CPaintDC基础
- 从零开始学HTML(六)--HTML 段落
- ATO SOLUTION NAND/MCP/SPI
- Flatten Binary Tree to Linked List
- 轻松解决 MyEclipse、Eclipse 编译时提示 @Override The method of type must override a superclass method 即 @Overr
- 第一章 2. CPaintDC 和 消息映射机制