views:

913

answers:

1

Are there any solutions or tools that transform java 5 code that uses all the new java 5 features(generics, autoboxing, varargs, static imports) into code that can run on a J2ME device? I am particularly interested in handling generics - the other features are nice to have but not mandatory.

I need source code as the result of this conversion as this will be compiled using a custom compiler. (I cannot use bytecode manipulation(ala retroweaver))

A: 

Compiling with the regular javac and targeting an older JVM will give you proper bytecode for generics at least.

If you really need source it's probably possible, though strange, to compile to bytecode and then decompile back to source.

orip
Nope. What it will give you is a compiler error. "javac: source release 1.5 requires target release 1.5". Apart from that, generics don't exist at the byte code level at all, so all you really have to do is remove them freom the source code.
Michael Borgwardt