Java Reference
In-Depth Information
If there is a single initializer expression, then it is assumed to initialize
an element called value . If there is no such element by that name, then
you will get a compile-time error. Combining this shorthand with the
shorthand for arrays with one element, you can rewrite the second use
of BugsFixed to be
@BugsFixed("457605")
You can have more than one element in the annotation type and still call
one of them value . If you do, and all other elements have default values,
then you can still use the shorthand form to initialize the value element.
However, once you have more than one initializer expression, you must
explicitly name each element.
Finally, you can annotate an annotation type with itself. For example,
the Documented marker annotation indicates that the program element
that is annotated should have its documentation comments processed-
see Chapter 19 . Because Documented should itself be documented it is an-
notated with itself:
@Documented
@interface Documented { }
Self-annotation is quite different from having an element of the annota-
tion type within the annotation typewhich, as you know, is not permit-
ted.
 
Search WWH ::




Custom Search