Annotations in Java 1.2 and up

I really like annotations, as do a large group of Java developers. Note that I avoided the word “love”, since I find that some developers are already abusing annotations by over-using them. However, there are plenty of developers out there that can’t use Java 5, and are stuck on 1.4; 1.3 and some on 1.2. I’ve stumbled on two great Open Source projects that let you use annotations (or something very similar) in earlier versions of Java. This can also be really useful to people developing on a platform that doesn’t yet allow Java 5 (like a MIDP application).

The first is Retroweaver, which allows almost all the Java 5 language features on earlier platforms by taking Java 5 bytecodes and re-writing them back into Java 4/3/2 compliant bytecodes. As part of it’s re-writing it maps several Java 5 API’s to it’s own runtime API (annotations included here).

The second API is much simpler and from the Jakarta project, it’s Commons-Attributes. Attributes has an Ant task which scans your JavaDocs for “@@…” attributes, and maps them to an XML file. The XML file can then be accessed by using the runtime API, which is less than 40k in size. The compiler and runtime API map the attributes to classes you write (a bit like annotations, except that they’re POJO’s).


One Response to “Annotations in Java 1.2 and up”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: