简体   繁体   中英

JarIndexAccess cannot access class jdk.internal.util.jar.JarIndex (in module java.base) in migrating jnlp from openjdk 8 to openjdk 9

We have below jnlp

<?xml version="1.0" encoding="UTF-8"?>
<!-- !DOCTYPE jnlp PUBLIC "-//Sun Microsystems, Inc//DTD JNLP Descriptor 6.0//EN" "http://java.sun.com/dtd/JNLP-6.0.dtd" -->
<jnlp spec="6.0+" codebase="$$codebase" href="$$name">
<information>
  <title>Softpaint</title>
  <vendor>Advanced Business Solutions</vendor>
  <homepage href="$$name" />
  <description>Softpaint</description>
  <offline-allowed/>
</information>

<security> 
   <all-permissions/> 
</security>
<resources>
  <property name="jnlp.packEnabled" value="true"/>
  <j2se version="9+" href="http://java.sun.com/products/autodl/j2se" java-vm-args="-ea 
  --add-opens=java.base/java.lang.reflect=ALL-UNNAMED
  --add-opens=java.base/jdk.internal.misc=ALL-UNNAMED
  --add-opens=java.base/sun.misc=ALL-UNNAMED 
  --add-opens=java.base/jdk.internal.util.jar=ALL-UNNAMED"
  initial-heap-size="128m" max-heap-size="512m" />
  <j2se version="1.8+" max-heap-size="256m">
    <resources>
      <jar href="rtwrapper.jar"/>
    </resources>
  </j2se>
  <j2se version="1.7*" max-heap-size="256m"/>  
  <jar href="e5wui-icons.jar" download="eager"/>
  <jar href="wuipsp.jar" main="true"/>
  <jar href="wuicli.jar"/>
  <jar href="wuiclires.jar"/>
  <jar href="wuisrv.jar"/>
  <jar href="wuitools.jar"/>
  <jar href="e5h5cli.jar"/>
  <package name="oracle.*" part="oracleoracle" recursive="true"/>
  <jar href="ojdbc6.jar" part="oracleoracle" download="lazy"/>
  <jar href="orai18n.jar" part="oracleoracle" download="lazy"/>
  <package name="com.ibm.db2.*" part="ibmdb2" recursive="true"/>
  <jar href="db2jcc4.jar" part="ibmdb2" download="lazy"/>
  <jar href="db2jcc_license_cisuz.jar" part="ibmdb2" download="lazy"/>
  <package name="com.microsoft.sqlserver.*" part="mssql" recursive="true"/>
  <jar href="sqljdbc4.jar" part="mssql" download="lazy"/>
  <package name="org.postgresql.*" part="postgresql" recursive="true"/>
  <jar href="postgresql-9.3-1101-jdbc41.jar" part="postgresql" download="lazy"/>
  <jar href="tools.jar"/>
  <jar href="slf4j-api.jar"/>
  <jar href="slf4j-jdk14.jar"/>
  <jar href="jcl-over-slf4j.jar"/>
  <jar href="swingx.jar"/>
</resources>
<application-desc 
    main-class="com.cedar.softpaint.ui.PersonalSoftpaint"/>
</jnlp>

Above jnlp working properly with oracle jdk 8. Now we are migrating to openjdk 9 and use icetea web to open the jnlp file on client side. Added j2se version="9+" with some java-args but faces below issues as sun/misc/JarIndex Class not found. I know that this class has been removed from openjdk 9 . So is it we need to use any alternate or do we have any workaround ?

Activate native: http://mahesh-pc:7050/e5softpaint/e5wui-icons.jar
java.lang.RuntimeException: java.lang.IllegalAccessException: class net.sourceforge.jnlp.jdk89acesses.JarIndexAccess cannot access class jdk.internal.util.jar.JarIndex (in module java.base) because module java.base does not export jdk.internal.util.jar to unnamed module @3b938003     at net.sourceforge.jnlp.jdk89acesses.JarIndexAccess.getJarIndex(JarIndexAccess.java:47)     at net.sourceforge.jnlp.runtime.JNLPClassLoader$2.run(JNLPClassLoader.java:1340)     at net.sourceforge.jnlp.runtime.JNLPClassLoader$2.run(JNLPClassLoader.java:1232)     at java.base/java.security.AccessController.doPrivileged(Native Method)     at net.sourceforge.jnlp.runtime.JNLPClassLoader.activateJars(JNLPClassLoader.java:1362)     at net.sourceforge.jnlp.runtime.JNLPClassLoader.initializeResources(JNLPClassLoader.java:785)     at net.sourceforge.jnlp.runtime.JNLPClassLoader.<init>(JNLPClassLoader.java:285)     at net.sourceforge.jnlp.runtime.JNLPClassLoader.createInstance(JNLPClassLoader.java:357)     at net.sourceforge.jnlp.runtime.JNLPClassLoader.getInstance(JNLPClassLoader.java:429)     at net.sourceforge.jnlp.runtime.JNLPClassLoader.getInstance(JNLPClassLoader.java:403)     at net.sourceforge.jnlp.Launcher.createApplication(Launcher.java:809)     at net.sourceforge.jnlp.Launcher.launchApplication(Launcher.java:529)     at net.sourceforge.jnlp.Launcher$TgThread.run(Launcher.java:940) Caused by: java.lang.IllegalAccessException: class net.sourceforge.jnlp.jdk89acesses.JarIndexAccess cannot access class jdk.internal.util.jar.JarIndex (in module java.base) because module java.base does not export jdk.internal.util.jar to unnamed module @3b938003     at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:361)     at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:589)     at java.base/java.lang.reflect.Method.invoke(Method.java:556)     at net.sourceforge.jnlp.jdk89acesses.JarIndexAccess.getJarIndexImpl(JarIndexAccess.java:53)     at net.sourceforge.jnlp.jdk89acesses.JarIndexAccess.getJarIndex(JarIndexAccess.java:45)     ... 12 more 
Running jdk9+ ?
java.lang.ClassNotFoundException: sun/misc/JarIndex     at java.base/java.lang.Class.forName0(Native Method)     at java.base/java.lang.Class.forName(Class.java:292)     at net.sourceforge.jnlp.jdk89acesses.JarIndexAccess.<clinit>(JarIndexAccess.java:23)     at net.sourceforge.jnlp.runtime.JNLPClassLoader$2.run(JNLPClassLoader.java:1340)     at net.sourceforge.jnlp.runtime.JNLPClassLoader$2.run(JNLPClassLoader.java:1232)     at java.base/java.security.AccessController.doPrivileged(Native Method)     at net.sourceforge.jnlp.runtime.JNLPClassLoader.activateJars(JNLPClassLoader.java:1362)     at net.sourceforge.jnlp.runtime.JNLPClassLoader.initializeResources(JNLPClassLoader.java:785)     at net.sourceforge.jnlp.runtime.JNLPClassLoader.<init>(JNLPClassLoader.java:285)     at net.sourceforge.jnlp.runtime.JNLPClassLoader.createInstance(JNLPClassLoader.java:357)     at net.sourceforge.jnlp.runtime.JNLPClassLoader.getInstance(JNLPClassLoader.java:429)     at net.sourceforge.jnlp.runtime.JNLPClassLoader.getInstance(JNLPClassLoader.java:403)     at net.sourceforge.jnlp.Launcher.createApplication(Launcher.java:809)     at net.sourceforge.jnlp.Launcher.launchApplication(Launcher.java:529)     at net.sourceforge.jnlp.Launcher$TgThread.run(Launcher.java:940)

JarIndex was moved in Java 9 to internal package dk.internal.util.jar.JarIndex

-import sun.misc.JarIndex;

+import jdk.internal.util.jar.JarIndex;

Due to JEP 260

sun.misc.JarIndex, and its accompanying InvalidJarIndexException, are not "Critical APIs", as defined by JEP 260, so they should be moved out of sun.misc and placed into a more appropriate package where they can be encapsulated.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM