Bytecode question

M

Martin Gregorie

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?
 
L

Lew

Martin said:
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?

Yes, modulo the presence of keywords like 'enum'. I've bundled 1.4 JARs with
Java 5 code before.
 
C

Chris Dollin

Lew said:
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.
 
A

Andrew Thompson

Martin said:
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. ;-)

--
Andrew Thompson
http://www.physci.org/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200712/1
 
R

Roedy Green

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.
 
M

Mike Schilling

Martin Gregorie said:
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?

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.
 
M

Martin Gregorie

Andrew said:
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. ;-)
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.
 
L

Lew

Chris said:
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.
 
M

Martin Gregorie

Mike said:
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.
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.
 
M

Mike Schilling

Martin Gregorie said:
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.

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top