2

I used to compile legacy Java code with Java 1.3, and run that in a Websphere Application Server v8.5. It is stable now.

Now I want to compile the code with Java 1.6, and I'd like the result to still run in Websphere Application Server v8.5. I can succeed in compiling the code.

What would happen if I compile the Java code with the newer Java version? Would it cause an error while running?

3
  • This question is not about compiler-construction. Don't tag indiscriminately. Commented Apr 11, 2016 at 3:57
  • Assuming that Webshphere still operates on Java 1.3, then no, you'll end up with a class version error. If Websphere runs Java 1.6 (or greater) then you shouldn't have an issue Commented Apr 11, 2016 at 3:58
  • Is the deprecation warnings in Javac the reason you are doing this? Commented Apr 11, 2016 at 5:45

1 Answer 1

2

In terms of actual syntax and compilation, the release notes for the different versions of Java are your best guide here. Of note would be Java 5's introduction of certain keywords, like assert and enum to the language which would actually cause compilation errors in your code base.

Aside from that, provided that the code actually did compile successfully (great, you didn't use any of the keywords!), then you have to take into account that behaviors between various classes have changed. They're available in the release notes too, and you should peruse them should you wish to avoid any breakage with your legacy code.

So in a nutshell, yes, your code could break if you use a higher version which relies on behaviors that have changed in newer versions.

There's also the matter of being sure that if you do compile your code with the newer JDK version, you must be sure that any JVM that deploys it uses at least that version or you will not be able to successfully run it.

Sign up to request clarification or add additional context in comments.

2 Comments

if the OP is deploying to WAS 8 then his code is running on a newer jre anyway (java 7 iirc) so he's already subjected to the newer jdk library versions. I fail to see any opportunity for breakage here (since it's already established the code compiles under the newer jdk).
@NathanHughes: Behavioral changes between classes may impact them; just running on the new JRE doesn't (to my recollection) mean that they're using any of the new classes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.