Just as you can annotate classes, you can also annotate your own custom annotations. This may seem a little silly at first blush, but if you begin to build up a large repository of customized notations, this becomes quite important. Just as Javadoc and comments are incredibly useful for a programmer studying a previously written class, meta-annotations, or annotations on annotations, are indispensable for figuring out someone else's intent for a customized annotation.
There are four standard meta-annotations, all defined in the java.lang.annotation package:
This meta-annotation specifies which program elements can have annotations of the defined type.
This meta-annotation indicates whether an annotation is tossed out by the compiler, or retained in the compiled class file. In cases where the annotation is retained, it also specifies whether it is read by the Java virtual machine at class load.
This meta-annotation indicates that the defined annotation should be considered as part of the public API of the annotated program element.
This meta-annotation is intended for use on annotation types that are targeted at classes, indicating that the annotated type is an inherited one.
These are all somewhat self-explanatory, so with a few examples, these meta-annotations should be easy to put into use. Each is covered in detail in the next several labs.