diff --git a/core/src/main/java/net/sourceforge/jnlp/runtime/JNLPRuntime.java b/core/src/main/java/net/sourceforge/jnlp/runtime/JNLPRuntime.java index 375f4db03..90b365492 100644 --- a/core/src/main/java/net/sourceforge/jnlp/runtime/JNLPRuntime.java +++ b/core/src/main/java/net/sourceforge/jnlp/runtime/JNLPRuntime.java @@ -41,7 +41,6 @@ import net.sourceforge.jnlp.util.RestrictedFileUtils; import net.sourceforge.jnlp.util.logging.LogConfig; import net.sourceforge.jnlp.util.logging.OutputController; -import sun.net.www.protocol.jar.URLJarFile; import javax.jnlp.ServiceManager; import javax.naming.ConfigurationException; @@ -300,8 +299,6 @@ public static void initialize() throws IllegalStateException { Security.setProperty("package.access", Security.getProperty("package.access")+",net.sourceforge.jnlp"); - URLJarFile.setCallBack(CachedJarFileCallback.getInstance()); - initialized = true; LOG.debug("End JNLPRuntime.initialize()"); } diff --git a/core/src/main/java/net/sourceforge/jnlp/runtime/classloader/JNLPClassLoader.java b/core/src/main/java/net/sourceforge/jnlp/runtime/classloader/JNLPClassLoader.java index dd3056a1b..d103ed899 100644 --- a/core/src/main/java/net/sourceforge/jnlp/runtime/classloader/JNLPClassLoader.java +++ b/core/src/main/java/net/sourceforge/jnlp/runtime/classloader/JNLPClassLoader.java @@ -46,7 +46,6 @@ import net.sourceforge.jnlp.cache.NativeLibraryStorage; import net.sourceforge.jnlp.config.ConfigurationConstants; import net.sourceforge.jnlp.runtime.ApplicationInstance; -import net.sourceforge.jnlp.runtime.CachedJarFileCallback; import net.sourceforge.jnlp.runtime.JNLPRuntime; import net.sourceforge.jnlp.security.AppVerifier; import net.sourceforge.jnlp.security.JNLPAppVerifier; @@ -1253,7 +1252,7 @@ private Void doActivateJars(List jars) { URL fileURL = new URL("file://" + extractedJarLocation); // there is no remote URL for this, so lets fake one URL fakeRemote = new URL(jar.getLocation().toString() + "!" + je.getName()); - CachedJarFileCallback.getInstance().addMapping(fakeRemote, fileURL); + //CachedJarFileCallback.getInstance().addMapping(fakeRemote, fileURL); addURL(fakeRemote); jarLocationSecurityMap.put(new UrlKey(fakeRemote), jarSecurity); @@ -1268,12 +1267,16 @@ private Void doActivateJars(List jars) { } } - addURL(jar.getLocation()); + if (localFile != null) { + addURL(localFile.toURI().toURL()); + } else { + addURL(jar.getLocation()); + } // there is currently no mechanism to cache files per // instance.. so only index cached files if (localFile != null) { - CachedJarFileCallback.getInstance().addMapping(jar.getLocation(), localFile.toURI().toURL()); + //CachedJarFileCallback.getInstance().addMapping(jar.getLocation(), localFile.toURI().toURL()); try (JarFile jarFile = new JarFile(localFile.getAbsolutePath())) { JarIndexAccess index = JarIndexAccess.getJarIndex(jarFile.getNative()); @@ -1282,7 +1285,7 @@ private Void doActivateJars(List jars) { } } } else { - CachedJarFileCallback.getInstance().addMapping(jar.getLocation(), jar.getLocation()); + //CachedJarFileCallback.getInstance().addMapping(jar.getLocation(), jar.getLocation()); } LOG.debug("Activate jar: {}", location); @@ -1573,9 +1576,12 @@ private void addNewJar(final JARDesc desc, UpdatePolicy updatePolicy) { return null; }); - addURL(remoteURL); - CachedJarFileCallback.getInstance().addMapping(remoteURL, cachedUrl); - + File localFile = tracker.getCacheFile(remoteURL); + if (localFile != null) { + addURL(remoteURL.toURI().toURL()); + } else { + addURL(remoteURL); + } } catch (Exception e) { // Do nothing. This code is called by loadClass which cannot // throw additional exceptions. So instead, just ignore it. diff --git a/core/src/test/java/net/sourceforge/jnlp/runtime/classloader/JNLPClassLoaderTest.java b/core/src/test/java/net/sourceforge/jnlp/runtime/classloader/JNLPClassLoaderTest.java index e2ef884e7..2e58ac779 100644 --- a/core/src/test/java/net/sourceforge/jnlp/runtime/classloader/JNLPClassLoaderTest.java +++ b/core/src/test/java/net/sourceforge/jnlp/runtime/classloader/JNLPClassLoaderTest.java @@ -84,7 +84,6 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; @NotThreadSafe @Ignore @@ -555,7 +554,6 @@ public void testLoadClass() throws Exception { JNLPRuntime.setSecurityEnabled(false); JNLPRuntime.setDebug(true); getConfiguration().setProperty(ConfigurationConstants.KEY_ENABLE_MANIFEST_ATTRIBUTES_CHECK, "NONE"); - URLJarFile.setCallBack(CachedJarFileCallback.getInstance()); final ServerLauncher as = ServerAccess.getIndependentInstance(jnlp.getParent(), port); try { @@ -569,7 +567,6 @@ public void testLoadClass() throws Exception { JNLPRuntime.setSecurityEnabled(securityBackup); JNLPRuntime.setDebug(verbose); getConfiguration().setProperty(ConfigurationConstants.KEY_ENABLE_MANIFEST_ATTRIBUTES_CHECK, manifestAttsBackup); - URLJarFile.setCallBack(null); as.stop(); clearCache();