aboutsummaryrefslogtreecommitdiffstats
path: root/netx/net/sourceforge
diff options
context:
space:
mode:
authorDeepak Bhole <[email protected]>2012-01-27 16:20:22 -0500
committerDeepak Bhole <[email protected]>2012-01-27 16:20:22 -0500
commit83a814966b14deb946e6c9fa9b55a75b9e22472d (patch)
treefcbbbb299fb410c64aa9f8ae7914775586f3454c /netx/net/sourceforge
parent8f98160184cfe24c20677937db590da40ea1926f (diff)
PR852: Classloader not being flushed after last applet from a site is closed
Diffstat (limited to 'netx/net/sourceforge')
-rw-r--r--netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java48
1 files changed, 47 insertions, 1 deletions
diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
index ba7f744..290902a 100644
--- a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
+++ b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
@@ -173,6 +173,11 @@ public class JNLPClassLoader extends URLClassLoader {
private boolean foundMainJar= false;
/**
+ * Variable to track how many times this loader is in use
+ */
+ private int useCount = 0;
+
+ /**
* Create a new JNLPClassLoader from the specified file.
*
* @param file the JNLP file
@@ -321,6 +326,7 @@ public class JNLPClassLoader extends URLClassLoader {
throw new LaunchException(file, null, R("LSFatal"), R("LCClient"), R("LSignedAppJarUsingUnsignedJar"), R("LSignedAppJarUsingUnsignedJarInfo"));
loader.merge(extLoader);
+ extLoader.decrementLoaderUseCount(); // loader urls have been merged, ext loader is no longer used
}
// loader is now current + ext. But we also need to think of
@@ -347,7 +353,11 @@ public class JNLPClassLoader extends URLClassLoader {
// loaders are mapped to a unique key. Only extensions and parent
// share a key, so it is safe to always share based on it
- urlToLoader.put(uniqueKey, loader);
+
+ loader.incrementLoaderUseCount();
+ synchronized(urlToLoader) {
+ urlToLoader.put(uniqueKey, loader);
+ }
return loader;
}
@@ -1762,6 +1772,42 @@ public class JNLPClassLoader extends URLClassLoader {
}
return result;
}
+
+ /**
+ * Increments loader use count by 1
+ *
+ * @throws SecurityException if caller is not trusted
+ */
+ private synchronized void incrementLoaderUseCount() {
+
+ // For use by trusted code only
+ if (System.getSecurityManager() != null)
+ System.getSecurityManager().checkPermission(new AllPermission());
+
+ useCount++;
+ }
+
+ /**
+ * Decrements loader use count by 1
+ *
+ * If count reaches 0, loader is removed from list of available loaders
+ *
+ * @throws SecurityException if caller is not trusted
+ */
+ public synchronized void decrementLoaderUseCount() {
+
+ // For use by trusted code only
+ if (System.getSecurityManager() != null)
+ System.getSecurityManager().checkPermission(new AllPermission());
+
+ useCount--;
+
+ if (useCount <= 0) {
+ synchronized(urlToLoader) {
+ urlToLoader.remove(file.getUniqueKey());
+ }
+ }
+ }
/*
* Helper class to expose protected URLClassLoader methods.