|
Re: How to use Java 5 on the cRIO
It does work reliably in terms of language features, however -- the compiled bytecode from Java 2 through Java 5 is fully backwards compatible; all the language features such as varargs, foreach loops, generics, and boxing/autoboxing are handled by the compiler and translated into the same bytecode. The only one I'm aware of as not being quite compatible is assertions, I'm trying to figure out what's missing there. (Something wrong with how the constant pool is accessed in <clinit>.)
Since they're essentially just syntactic sugar for something else, they aren't actually adding overhead in terms of memory/runtime. Obviously you can't use foreach loops on non-array objects until you've added the collections API, or at least Iterator/Iterable, but once you /have/ put those in it will link against them correctly and work. (you can already use them over arrays, because that gets translated into just an index.)
It's probably unwise to just drop in all of java.util.* to your project, but certainly adding Iterator/Iterable/List/AbstractList/ArrayList/Map/AbstractMap/HashMap will make some people happier, I think, and it won't add much in terms of memory usage.
Matthew, I haven't run full-scale quantities of code, but since I know the bytecode and I know that features such as generics don't actually have any performance change, I feel very confident when I say they won't negatively influence it. As for why higher JavaME versions become incompatible, at least in later versions of Java there is eventually an invokedynamic opcode added (for lambdas) that will definitely not work. You may also run into trouble with the compiler producing stack map tables that the romizer may or may not accept. I didn't try any higher versions, though, since I felt like Java 5 was "good enough" to feel like modern Java in a lot of ways.
Edit: As far as I know a main reason for opting to use an earlier version of Java would probably be the modifications to the Java Memory Model that imposed certain restrictions on how multithreading should work. The performance hasn't fundamentally changed.
Last edited by Timeroot : 01-08-2014 at 12:56.
|