Invalid class called in Java 9 multi-release JAR file?

I see a problem with an applet using JAR with multiple releases, and I hope someone can help me.

I have a very simplified file with several versions of jar with a class called VersionDependent. Its “version” method should display “Java 9 Version” when running on the Java 9 JRE system and display “Java 8 or earlier version” while running on the Java JRE system.

When I launch the applet by entering this URL ( http: //10.nnn.nn.nn/testLAC.html ) into my browser (Internet Explorer V11) on the client machine, Java JRE 9, everything works correctly; it displays a "version of Java 9" as expected.

But when I launch the applet by entering this URL (file: /// C: /FOLDER_NAME/testLAC.html) on the same client computer to view the page locally, "Java 8 or earlier version" suddenly appears. It seems that Java 9 defined for the VersionDependent version of the Multi-release Jar class is not being called. Can someone help me understand why the multidisciplinary JAR does not work as expected? Only Java JRE 9 is installed on the client machine.

Here are the contents of a multi-release 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 

Here is the applet test code that displays the Java JRE version and then calls in 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, 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",10,70); } else { String a = "VersionDependent.version is not null. Output: " + test; g.drawString(a,10,90); } } public void init() { } } 

Finally, here is an HTML file that uses the JAR and JAR test applet with multiple releases:

 <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, the corresponding Java 9 class is called.

New update: When I use appletviewer in an html file (after you select "%" in width and height), the corresponding Java 9 class is called.

Another new update. The employee converted the applet for local use of the JNLP file on the client and called the wrong java class. But when she changed the code field in the local JNLP file to point to the remote server, the resources were downloaded from the server and the corresponding Java 9 class was called.

Can someone help me with this problem? How could I better fix the problem? I could post Java console output for “work cases” and “crashes” if that helps. I asked to create an error report: http://bugreport.java.com .
I was given an automatic internal review ID: 9051408

New update: now Oracle can reproduce the problem and created this problem: https://bugs.openjdk.java.net/browse/JDK-8191541

And here is the implementation of Java 9 and pre-Java 9 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"; } } 
+7
java jar java-9 multi-release-jar
source share
1 answer

Now Oracle can reproduce the problem in JDK 9 / 9.0.1 and created this problem under # JDK-8191541 , where you can keep track of current updates.

Update: JDK-8191541 has been marked as duplicate # JDK-8192748 and will be fixed in JDK10 (scheduled to be released in March 2018).

I asked Oracle if they plan to port the patch to JDK9.

Update 1/29/2018: Oracle announced that they would NOT return the patch patch to JDK9.

Update: 1/29/2018: Oracle pointed me to an earlier version of JDK 10, which should have a fix: http://jdk.java.net/10/ Unfortunately, when I tried the same test with multiple versions of JAR with Java JDK 10 EA, the problem remains. I am creating another error record, this time against JDK 10 EA.

I will post another update if / when there is a solution or workaround.

+2
source share

All Articles