Message-ID: <523496566.300610.1369061632066.JavaMail.email@example.com> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_300609_450176021.1369061632065" ------=_Part_300609_450176021.1369061632065 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
When you are writing your annotation in JavaDoc, you need to post-compil= e your classes in order to parse the sources, retrieve the JavaDoc annotati= ons, process and validate the annotations and finally put them into the byt= ecode as regular Java 5 RuntimeVisible annotations.
This is done by using the backport175 compiler,
You can run
AnnotationC either from the command line or usi=
ng the Ant task.
You invoke the compiler like this:=20
The last option
-config <property file(s)> points to =
the (or several files separated by classpath separator -
; or =
: depending on you OS) property file which defines annotation =
aliases (or imports) by mapping the names to the fully qualified class name=
s of the annotation interface.
Note that if you are using the
-dest option, the anonymous =
inner classes will not be copied to the destination directory, since the an=
onymous classes are not taken into account by the annotation compiler. In s=
uch a case it is recommended to add the following (if using Ant) j=
ust after the call to
AnnotationC when the
option is used: (adapt according to the directories you are using)
Since the annotations are written in JavaDoc, there is no way of doing i= mports of the annotations interfaces.
This leaves you two options:
You can have more than one annotation.properties file (see the compiler = section) and those are not at all required at runtime.
It is important to remember that if you are using an alias through a pro=
pery file, the annotation name is still the fully qualified name of the int=
erface class for the annotation when using the
If you decide to use an alias, then you have to use this alias in the wh=
ole sources. It is not possible to use from time to time in the source an a=
lias or the fully qualified name, since backport175 has to ensure an elemen=
t cannot be annotated twice with the same annotation, as per JSR-175.
If you decide to use the fully qualified name, the same rule applies, it ne= eds to stay consistent.
If the annotation is a nested class like
w, you can use a
$ in the name (as when using java.lang.reflec=
t.* API) or a
. which can be more readable.
Once again, this choice has to be consistent thus one or the other has to b= e used accross the code base but not both:
or (with dot)
JSR-175 annotation support default values. This is supported in backport=
175 with the
org.codehaus.backport175.DefaultValue special ann=
otation, that only accepts one single anonymous value whose type must match=
the one of the annotation element which has this default value :