Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 13 Next »

Java 5 annotations

Java 5 annotations are standardized through the

Error rendering macro 'link' : Link needs a name and a URL as arguments.
. When you compile annotated source code the javac compiler will embed the annotations in the compiled class, and this information can then be read back using the reflection API.

Annotations in Java 5 are first class citizen through the @interface keyword.

backport175 annotations for Java 1.3/1.4

backport175 is an implementation of the

Error rendering macro 'link' : Link needs a name and a URL as arguments.
for Java 1.3/1.4 which provides the same user experience as regular Java 5 annotations.

Annotations are defined using a regular Java interface (hence providing strongly typed access to annotation values), and annotated source code appears in the form of doclet in the JavaDoc part.

The backport175 compiler (available through command line or as an Ant task) allows you to post-compile your classes to embed the annotation information inside the class' bytecode. The annotations are bytecode compatible with regular Java 5 annotations and therefore can be treated the same by tools, regular Java reflection (on Java 5) etc.

Note: it is advised to have a space between the annotation and its value as below though not mandatory.

The annotations can then be accessed using the API in the org.codehaus.backport175.reader.Annotations class which allows to retrieve reflectively both regular Java 5 annotations and Java 1.3/1.4 annotations in a consistent way, allowing you to adopt annotation driven development even without Java 5, while having a simple migration path. For more information on how to access annotations, read this section.

  • No labels