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 6 Next »

Java 5 annotations

Java 5 annotations are standardized through the JSR-175 specification. 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 annotations provide the same user experience. 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.

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