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
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.
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:
♦
V
is not
null
.
♦ 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.