Search code examples
javajvmjvm-hotspot

Java 5 runtime in Java 6 Hotspot


Is there a way to run Java 6's Hotspot with Java 5's runtime environment? I have some code that depends on the behavior of older implementations of classes, but I'd like to use a more recent JVM. I do have plans to migrate the code to Java 6 (or maybe 7!), but right now, I'm more concerned with seeing if I have a JVM issue.


Solution

  • I think you are better off with one of the following:

    • Figure out if you can modify your application code to work around the XSLT bug in Java 6.

    • Find out if there is a Sun/Oracle supported patch for the XSLT bug on Java 6.

    • Use a Java 5 JRE.

    • Try the latest Java 6 JRE to see if the XSLT bug is fixed there.

    • Try the latest Java 7 JRE to see if the XSLT bug is fixed there.

    The problem with using a Java 5 rt.jar on a Java 6 JVM is that there are hidden dependencies between core classes in the rt.jar and the native code implementation of the JVM; i.e. java binary and associated native libraries. These are not documented, and it is (IMO) highly likely that some of them changed between Java 5 and Java 6.


    If there are native incompatibilities between the two, it looks like I'm left with grabbing the specific classes I need and either replacing them in rt.jar or overriding them with extdir.

    Hacking Java like that is not a good idea. At a minimum, you'll have to repeat the hackery each time you download and install the latest Java 6 JRE on your application's platform. (And if you are supplying this application to others, then THEY have the problem too.)

    And there are still 2 alternatives in my original that you could use instead: fix the application to workaround the problem, and stay with Java 5.


    The bug exists in the Java 7's XSLT and in the latest Xalan

    Have you considered the possibility that this is not a bug at all? Maybe it is a fix for a previous bug or allowed behavior within the scope of the relevant specs, and your code is at fault for depending on the previous (buggy?) behavior.

    Are there bug reports in the Java / Xalan bug databases for this bug? What do the maintainers say? Do they offer workarounds? (These questions NEED to be asked ...)