.class with JDK1.2 --> run with JRE1.4 ???

Q

qazmlp

Assume that, I have generated a .class file after compiling a java
program with the JDK1.2.
Is it 100% guaranteed always that, this program will run without any
problems under the JRE1.4 environment? If yes/no, why?
 
J

John C. Bollinger

qazmlp said:
Assume that, I have generated a .class file after compiling a java
program with the JDK1.2.
Is it 100% guaranteed always that, this program will run without any
problems under the JRE1.4 environment? If yes/no, why?

It depends what you mean by that. The class file format has not changed
since Java 1.0. The VMs for 1.4 will correctly run bytecode produced by
the JDK 1.2 compiler. Compatibility issues arise (a bit) when you start
looking at the platform library. As far as I am aware, nothing from the
1.2 library has been removed from 1.4, although some methods are now
deprecated.

You may run into trouble if your 1.2 classes extend classes from the
platform library or implement interfaces from the platform library.
Where a new abstract method has been added to a class or a method has
been added to an interface since 1.2, your concrete classes may suddenly
become abstract when run against the 1.4 library. I am not aware
offhand of any classes to which this would apply, but there may be some.
There certainly are some interfaces to which it applies, but none I am
aware of that are commonly implemented by user code. I can imagine some
cases in which interaction of the 1.4 classes with your code would
produce unexpected results because of new concrete methods added to the
platform classes (and unwittingly inherited by your classes), but I
think such cases are generally unlikely.

Your best bet is to actually test. If you have a unit test suite then
that's easy. If not, then maybe now is the time to write one. If you
don't want to write one then you can still test manually (and you can
look forward to future rounds of manual testing, too).


John Bollinger
(e-mail address removed)
 
O

ohaya

John C. Bollinger said:
It depends what you mean by that. The class file format has not changed
since Java 1.0. The VMs for 1.4 will correctly run bytecode produced by
the JDK 1.2 compiler. Compatibility issues arise (a bit) when you start
looking at the platform library. As far as I am aware, nothing from the
1.2 library has been removed from 1.4, although some methods are now
deprecated.

You may run into trouble if your 1.2 classes extend classes from the
platform library or implement interfaces from the platform library.
Where a new abstract method has been added to a class or a method has
been added to an interface since 1.2, your concrete classes may suddenly
become abstract when run against the 1.4 library. I am not aware
offhand of any classes to which this would apply, but there may be some.
There certainly are some interfaces to which it applies, but none I am
aware of that are commonly implemented by user code. I can imagine some
cases in which interaction of the 1.4 classes with your code would
produce unexpected results because of new concrete methods added to the
platform classes (and unwittingly inherited by your classes), but I
think such cases are generally unlikely.

Your best bet is to actually test. If you have a unit test suite then
that's easy. If not, then maybe now is the time to write one. If you
don't want to write one then you can still test manually (and you can
look forward to future rounds of manual testing, too).


John,

My apologies for dropping in on this thread, but a couple of weeks ago,
I had posted some questions related to serialized objects (in files).
In general, wouldn't something like that be another potential problem
area, e.g., if the format of the serialized data has changed between
versions (I don't think it did between 1.2 and 1.4)?

Jim
 
J

John C. Bollinger

ohaya said:
My apologies for dropping in on this thread, but a couple of weeks ago,
I had posted some questions related to serialized objects (in files).
In general, wouldn't something like that be another potential problem
area, e.g., if the format of the serialized data has changed between
versions (I don't think it did between 1.2 and 1.4)?

There is a potential for difficulty here if serialized objects are used
for persistent storage. Depending on the classes involved it might or
might not work. Serialization is a terrible approach for persistent
object storage, however, in part for that very reason. There is also a
potential for problems if serialization is used for object transport,
for instance in an RMI application. The Serialization subsystem has
mechanisms to address that, but it is possible (if unlikely) to run into
unresolvable difficulties when one side of the link is using a different
version of the platform library than the other side.


John Bollinger
(e-mail address removed)
 

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,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top