I've seen a lot of discussion about source code compatibility between
JDK versions. That all seems straight forward. I also know that, if
source code written to the 1.4 standard is compiled is with the JDK 1.5
compiler the result can't be run in a 1.4 JVM.
However, what about forward bytecode compatibility. Can code compiled
with the JDK 1.4 compiler be run in a 1.5 or 1.6 JVM?

Signature
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
Lew - 14 Dec 2007 14:07 GMT
> I've seen a lot of discussion about source code compatibility between
> JDK versions. That all seems straight forward. I also know that, if
[quoted text clipped - 3 lines]
> However, what about forward bytecode compatibility. Can code compiled
> with the JDK 1.4 compiler be run in a 1.5 or 1.6 JVM?
Yes, modulo the presence of keywords like 'enum'. I've bundled 1.4 JARs with
Java 5 code before.

Signature
Lew
Chris Dollin - 14 Dec 2007 14:26 GMT
>> I've seen a lot of discussion about source code compatibility between
>> JDK versions. That all seems straight forward. I also know that, if
[quoted text clipped - 5 lines]
>
> Yes, modulo the presence of keywords like 'enum'.
I think Martin meant the /compiled/ code, which doesn't have keywords
at all: "forward /bytecode/ compatibility", my emphasis.

Signature
Chris "it's Friday" Dollin
Hewlett-Packard Limited registered office: Cain Road, Bracknell,
registered no: 690597 England Berks RG12 1HN
Lew - 15 Dec 2007 00:38 GMT
>>> I've seen a lot of discussion about source code compatibility between
>>> JDK versions. That all seems straight forward. I also know that, if
[quoted text clipped - 7 lines]
> I think Martin meant the /compiled/ code, which doesn't have keywords
> at all: "forward /bytecode/ compatibility", my emphasis.
Y'know, I was reading the question wrong, about /backward/ compatibility. My
error.

Signature
Lew
Andrew Thompson - 14 Dec 2007 14:41 GMT
>I've seen a lot of discussion about source code compatibility between
>JDK versions. That all seems straight forward. I also know that, if
>source code written to the 1.4 standard is compiled is with the JDK 1.5
>compiler the result can't be run in a 1.4 JVM.
That is not entirely correct. So long as the
-source/-target *&* -bootclasspath* are specified,
a 1.6 (or 1.5) compiler can compile code
*guaranteed* to be suitable for a Java 1.1 VM.
* bcp is the tricky one. ;-)

Signature
Andrew Thompson
http://www.physci.org/
Martin Gregorie - 15 Dec 2007 00:37 GMT
>> I've seen a lot of discussion about source code compatibility between
>> JDK versions. That all seems straight forward. I also know that, if
[quoted text clipped - 7 lines]
>
> * bcp is the tricky one. ;-)
Fair comment and thanks for describing the override.
Unfortunately I wasn't in a position to use it. A bit over 2 years ago I
needed to run CoCo/R with JDK 1.4. It didn't. Asking got me the
information that it was compiled with 1.5. I wasn't in a position to d/l
JDK 1.5, thanks to a 56K dialup with per minute billing, so I recompiled
the source under 1.4 and it all worked perfectly.

Signature
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
Roedy Green - 14 Dec 2007 15:45 GMT
On Fri, 14 Dec 2007 13:12:49 +0000, Martin Gregorie
<martin@see.sig.for.address> wrote, quoted or indirectly quoted
someone who said :
>However, what about forward bytecode compatibility. Can code compiled
>with the JDK 1.4 compiler be run in a 1.5 or 1.6 JVM?
yes.
Without that feature it would be impossible for Applets to function.

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Martin Gregorie - 15 Dec 2007 00:38 GMT
> On Fri, 14 Dec 2007 13:12:49 +0000, Martin Gregorie
> <martin@see.sig.for.address> wrote, quoted or indirectly quoted
[quoted text clipped - 5 lines]
>
> Without that feature it would be impossible for Applets to function.
That makes sense. Thanks for the heads-up.

Signature
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
Mike Schilling - 14 Dec 2007 17:08 GMT
> I've seen a lot of discussion about source code compatibility
> between JDK versions. That all seems straight forward. I also know
[quoted text clipped - 3 lines]
> However, what about forward bytecode compatibility. Can code
> compiled with the JDK 1.4 compiler be run in a 1.5 or 1.6 JVM?
Yes. Otherwise, when you installed a new version of the JRE you'd
become unable to run any of your existing Java programs. This would
be a Bad Thing.
Martin Gregorie - 15 Dec 2007 00:53 GMT
>> I've seen a lot of discussion about source code compatibility
>> between JDK versions. That all seems straight forward. I also know
[quoted text clipped - 7 lines]
> become unable to run any of your existing Java programs. This would
> be a Bad Thing.
Agreed, but I've been there in the past and needed to recompile everything.
Clib updates, dynamically linked C programs and early versions of Linux
spring to mind. I'm certain I've seen the same in Windows environments too.
Way back in the late Jurassic Era (i.e the late 60s) ICL's George 3 OS
guaranteed forward and backward compatibility of 1 major version for
programs and the filing system. If version 7.01 fell over, you just
rebooted the previous running version (6.64 for instance) and kept the
service running. When you got a patch for 7.01 you booted that to see if
the problem was fixed. This sequence could be repeated as nauseum and,
yes, you could even automate the fallback.
I just wish that this is something that was remembered AND IMPLEMENTED
by the current authors of OSen, compilers and databases.

Signature
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
Mike Schilling - 15 Dec 2007 02:29 GMT
>>> I've seen a lot of discussion about source code compatibility
>>> between JDK versions. That all seems straight forward. I also know
[quoted text clipped - 12 lines]
> Linux spring to mind. I'm certain I've seen the same in Windows
> environments too.
I know exactly what you mean, but even in the past, some environments
worked much better than that (VAX/VMS, for instance); fortunately;
Java does too.