I'd used Retroweaver
in the past though it seems a bit dead lately and had quite a few
missing features (like annotations and various new JDK 5 methods along
with backport-util-concurrent). I started hacking it to try add
java.util.concurrent support (using backport-util-concurrent). Then I spotted Retrotranslator. DOH!
rocks! Its similar to Retroweaver but using a BSD license, nicely
written, fully unit tested and using just ASM (3.0-beta currently). Its
a great piece of work.
Using it you can take some Java 1.5 bytecode using annotations,
generics, auto-boxing, java.util.concurrent utilities and port it to
1.4 compliant bytecode; you just need to add
retrotranslator-runtime.jar then asm.jar (for accessing annotations)
and backport-util-concurrent.jar for using java.util.concurrent
There are still a few methods and classes in the java.* namespace that
have not been completely backported yet, but most things you want to do
I've been trying to get JAXB 2 RI working on 1.4 and its kinda close
thanks to Retrotranslator; all the Java 5 code I've tried works
perfectly with Retrotranslator though JAXB 2 is using some of the edge
cases not supported yet - fingers crossed they get fixed soon.
So if you really must support Java 1.4 but want to use annotations,
generics and java.util.concurrent its well worth taking Retrotranslator
for a spin; though as always, test your code to check it works :)