Most of the language changes in the new 1.5.0 Beta seem to be changes
that could be implemented pretty simply by the compiler, without any
changes made to the bytecode format.
So, I'm curious...if I compile code that uses the new 1.5.0 features,
can I subsequently execute those bytecode in the 1.4.2_03 JVM?
Michael Amling - 07 Feb 2004 03:01 GMT
> Most of the language changes in the new 1.5.0 Beta seem to be changes
> that could be implemented pretty simply by the compiler, without any
> changes made to the bytecode format.
>
> So, I'm curious...if I compile code that uses the new 1.5.0 features,
> can I subsequently execute those bytecode in the 1.4.2_03 JVM?
I haven't looked, but even if the bytecodes haven't changed (and I
suspect they haven't), there's a danger that a builtin class in 1.5 may
not exist in 1.4 or may not have all the fields or methods that 1.5 has.
--Mike Amling
Chris Uppal - 07 Feb 2004 10:40 GMT
> So, I'm curious...if I compile code that uses the new 1.5.0 features,
> can I subsequently execute those bytecode in the 1.4.2_03 JVM?
All the new semantics is realized through tricks that work just as well on
pre-1.5 JVMs. A few new attributes have been added, but that's completely
downwards compatible.
However, from a post by Neil Grafter on c.l.j.programmer:
You can translate 1.5-style classfiles into 1.4-style classfiles
by discarding the stackmaps and changing the version number.
Almost. Class literals generate a single bytecode instruction
(ldc) in 1.5, and that must be translated into the mass of code
that was used in previous releases.
So I suspect that (if the feature makes it into the final release) code
compiled with -target 1.5 may not be able to run on a 1.4 JVM (but then, I
don't suppose it would anyway given the version number checking).
-- chris