Java 5-compiled binaries on Java 1.3 runtime
May I know if there are any issues running a Java 5-compiled code (with Java 1.3 source/target compliance) on a Java 1.3 JVM?
I know this is quite odd, but most of our customers are on Java 5 but we are restricted by a few still on Java 1.3 due to conditions beyond our control开发者_如何学Python. Our CI tool uses Java 5 compiler but we set our source and target compliance to Java 1.3 for backward compatibility. We are not using Java 1.3 for CI because there are unit tests that does not compile on 1.3.
Will this be an issue?
Thank you in advance!
Cheers, - Paul
The only way to get the compiler to check that source in your app. only uses 1.3 methods is to specify a -bootclasspath
pointing to a 1.3 rt.jar. Note you can get that from a 1.3 JRE, it does not require a 1.3 SDK/compiler. Of course, specify a -target
of 1.3.
The biggest problem you will have is that while the JVM generated byte code will be compliant with 1.3, the JDK you're compiling against is Java 5. It is very easy to use a class, or more likely, a method that exists in Java 5, but not in the 1.3 JDK. This code will compile fine but will fail to run on a 1.3 runtime.
精彩评论