...
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.
| Code Block | ||
|---|---|---|
| ||
// A Java 1.3/1.4 Annotation with backport175
public interface Asynchronous {
/**
* Default value is supported through this specific annotation
*
* @org.codehaus.backport175.DefaultValue (5)
*/
int timeout();
String label();
}
// A Java 1.3/1.4 annotated method
/**
* @Asynchronous (timeout=5, label="will run for a while")
*/
public Object someMethod() {
...
}
|
...
