The wrong class was called in the multi version JAR file on Java 9?
I found a problem with the applet using multiple versions of jar. I hope someone can help me
I have a very simplified multi - version jar file with a class called versiondependent Its method "version" should display "Java 9 version" when running on Java 9 JRE system and "Java 8 or earlier" when running on Java 8 JRE system
When I pass this URL on a client computer running Java JRE 9( http://10.nnn.nn.nn/testLAC.html )When you enter my browser (Internet Explorer V11) to run the applet, everything is normal; It displays the Java 9 version as expected
However, when I run the applet to view the page locally by entering this URL on the same client computer (file: / / / C: / folder_name / testlac. HTML), it unexpectedly displays "Java 8 or earlier" It seems that the Java 9 specific versiondependent class of the multi release jar will not be called Can someone help me understand why multi version jars don't work as expected? Only Java JRE 9.0 is installed on the client computer
The following is the content of the multi version jar file:
jar tvf mr.jar | more 0 Mon Oct 23 08:52:38 EDT 2017 Meta-INF/ 82 Mon Oct 23 08:52:38 EDT 2017 Meta-INF/MANIFEST.MF (This has Multi-Release: true !) 0 Thu Jun 08 07:58:28 EDT 2017 com/ 0 Thu Jun 08 07:58:28 EDT 2017 com/emc/ 0 Mon Oct 23 08:50:40 EDT 2017 com/emc/demo/ 324 Mon Oct 23 08:43:44 EDT 2017 com/emc/demo/VersionDependent.class 0 Thu Jun 08 07:58:28 EDT 2017 Meta-INF/versions/9/ 0 Thu Jun 08 07:58:28 EDT 2017 Meta-INF/versions/9/com/ 0 Thu Jun 08 07:58:28 EDT 2017 Meta-INF/versions/9/com/emc/ 0 Thu Jun 08 08:24:32 EDT 2017 Meta-INF/versions/9/com/emc/demo/ 313 Mon Oct 23 08:47:34 EDT 2017 Meta-INF/versions/9/com/emc/demo/VersionDependent.class
The following is the test of Applet code, which displays the version of Java JRE, and then calls VersionDependent.. version:
package appletExample; //Reference the required Java libraries import java.applet.Applet; import java.awt.*; import com.emc.demo.VersionDependent; //The applet code public class TestAppletLAC extends Applet { private Button button1; public void paint(Graphics g) { // Draw a rectangle width=250,height=100 g.drawRect(0,500,100); // Set the color to blue g.setColor(Color.blue); g.drawString("Major version: " + System.getProperty("java.version"),10,50); String test = new VersionDependent().version(); if(test == null){ g.drawString("VersionDependent.version is null",70); } else { String a = "VersionDependent.version is not null. Output: " + test; g.drawString(a,90); } } public void init() { } }
Finally, this is the HTML file using the test applet jar and multi version jar:
<HTML> <HEAD> <TITLE></TITLE> <Meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <Meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> </HEAD> <BODY topmargin="0" leftmargin="0" marginwidth="0" marginheight="0"> <applet codebase="." mayscript="true" width="100%" height="100%" codebase_lookup="false" START_BACKGROUND="65A0EA" END_BACKGROUND="2F63AC" code="appletExample.TestAppletLAC" archive="mr.jar,testAppletLAC.jar" name="FxApplet"> <param name="separate_jvm" value="true"/><param name="java_arguments" value="-Djnlp.packEnabled=false"/><param name="codebase_lookup" value="false"/> </applet> </HTML>
When I run from the command line, I call the appropriate Java 9 class
New update: when I use appletviewer on HTML files (after taking "%" from width and height), call the appropriate Java 9 class
Another new update: a colleague converted the applet to use the JNLP file locally on the client and called the wrong Java class However, when she changed the codebase field in the local JNLP file to point to the remote server, the resource downloaded from the server and called the correct Java 9 class
Can anyone help me solve this problem? How can I solve the problem better? If it helps, I can publish Java console output of "work cases" and "failure cases" I have asked to create an error report here: http://bugreport.java.com. I got an automatic internal review ID: 9051408
New update: Oracle can now reproduce the problem and create it: https://bugs.openjdk.java.net/browse/JDK-8191541
The following are Java 9 and pre Java 9 implementations of versiondependent:
package com.emc.demo; /** * This is the Java 9 version of the class `VersionDependent`. */ public class VersionDependent { public String version() { return "Java 9 version"; } } package com.emc.demo; /** * This is the pre Java 9 version of the class `VersionDependent`. */ public class VersionDependent { public String version() { return "Java 8 or earlier version"; } }
Solution
Oracle is now available in JDK 9 / 9.0 1, and created this problem under #jdk-8191541, where you can track the current update
Update: jdk-8191541 has been marked as a copy of #jdk-8192748 and will be repaired in jdk10 (planned to be released in March 2018)
I asked them if they planned to migrate the fix to JDK 9
Update 1 / 29 / 2018: Oracle reports that they will not migrate the fix back to jdk9
Update: 1 / 29 / 2018: Oracle pointed out to me that the earlier version of JDK 10 should be fixed: http://jdk.java.net/10/ Unfortunately, when I try the same multi - version jar test using java JDK 10 EA, the problem still exists I'm creating another error entry, this time for JDK 10 EA
If / when there is a solution or solution, I will publish another update