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)