Java Reference
In-Depth Information
ElementValue:
ConditionalExpression
Annotation
ElementValueArrayInitializer
ElementValueArrayInitializer:
{ ElementValues opt , opt }
ElementValues:
ElementValue
ElementValues , ElementValue
The TypeName names the annotation type corresponding to the annotation.
Note that the at-sign ( @ ) is a token unto itself. Technically it is possible to put
whitespace between it and the TypeName , but this is discouraged as a matter of style.
It is a compile-time error if TypeName does not name an annotation type that is accessible
6.6 ) at the point where the annotation is used.
The Identifier in an ElementValuePair must be the simple name of one of the elements (i.e.
methods) of the annotation type identified by TypeName ; otherwise, a compile-time error
occurs.
The return type of this method defines the element type of the element-value pair.
An ElementValueArrayInitializer is similar to a normal array initializer (§ 10.6 ) , except that
annotations are permitted in place of expressions.
An element type T is commensurate with an element value V if and only if one of the fol-
lowing conditions is true:
T is an array type E [] and either:
V is an ElementValueArrayInitializer and each ElementValue (analogous to a
VariableInitializer in an array initializer) in V is commensurate with E ; or
V is an ElementValue that is commensurate with E .
• The type of V is assignment compatible (§ 5.2 ) with T , and furthermore:
♦ If T is a primitive type or String , and V is a constant expression (§ 15.28 ).
V is not null .
♦ If T is Class , or an invocation of Class , and V is a class literal (§ 15.8.2 ).
♦ If T is an enum type, and V is an enum constant.
Note that null is not a legal element value for any element type.
Search WWH ::




Custom Search