Reference: Java Official document http://docs.oracle.com/javase/specs/jls/se7/html/jls-9.html#jls-9.6
Annotation type:
is a special type of interface, except that the annotation declaration is @interface
Features:
1.Java annotations cannot explicitly declare a parent class (in fact they all inherit the annotation class, but you cannot use the extends keyword when declaring), nor can it be generalized.
2. Method:
a) Each method defines an element in the annotation (each of the methods declaration in an annotation type declaration defines an Element of the annotation type).
b) The method parameter in the annotation can not have parameters
c) Methods in annotations can not throw exceptions
d) The return value of the method (that is, the element of the annotation) must be one of the following:a primitive type (base type: int, float, etc.),String, Class, parameterized invocation ofClass, enum, Annotation,array
(parameterized invocation Class of: After Java 5 java.lang.Class is a generic class, meaning that he can have type parameters, specifically refers to the form of class<...>, for example: class< extends formatter> value (); )
e) If the declaration of a method does not have the default keyword, it must be assigned using the generic type
D) If you want to create a framework that calls annotations through reflection during run time, you need your annotations annotated @retention (retentionpolicy.runtime), otherwise the annotations may be eliminated during compilation.
3. if no special declaration, annotations and interface (all static fields)
Java annotation Annotations