aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeepak Bhole <dbhole@redhat.com>2012-01-27 16:20:22 -0500
committerDeepak Bhole <dbhole@redhat.com>2012-01-27 16:20:22 -0500
commit83a814966b14deb946e6c9fa9b55a75b9e22472d (patch)
treefcbbbb299fb410c64aa9f8ae7914775586f3454c
parent8f98160184cfe24c20677937db590da40ea1926f (diff)
PR852: Classloader not being flushed after last applet from a site is closed
-rw-r--r--ChangeLog12
-rw-r--r--NEWS1
-rw-r--r--netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java48
-rw-r--r--plugin/icedteanp/java/sun/applet/PluginAppletViewer.java3
4 files changed, 63 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index e2698c7..ae6b1c4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2012-01-27 Deepak Bhole <dbhole@redhat.com>
+
+ PR852: Classloader not being flushed after last applet from a site is closed
+ * netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java: Added variable
+ to count usage for a given ClassLoader instance.
+ (getInstance): Decrement use count for a loader after it is merged with
+ another. Increment loader use count before returning.
+ (incrementLoaderUseCount): New method. Increments loader use count.
+ (decrementLoaderUseCount): New method. Decrements loader use count.
+ * java/sun/applet/PluginAppletViewer.java (appletClose): Decrement loader
+ use count when applet is closed.
+
2012-01-25 Jiri Vanek <jvanek@redhat.com>
Added test for -Xnofork option and for applet launching by jnlp
diff --git a/NEWS b/NEWS
index 42fe1da..91c9d73 100644
--- a/NEWS
+++ b/NEWS
@@ -22,6 +22,7 @@ New in release 1.2 (2011-XX-XX):
- PR749: sun.applet.PluginStreamHandler#handleMessage(String) really slow
- PR782: Support building against npapi-sdk as well
- PR838: IcedTea plugin crashes with chrome browser when javascript is executed
+ - PR852: Classloader not being flushed after last applet from a site is closed
- RH586194: Unable to connect to connect with Juniper VPN client
- RH718693: MindTerm SSH Applet doesn't work
Common
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.
diff --git a/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java b/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java
index f51c1e8..6f4f2eb 100644
--- a/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java
+++ b/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java
@@ -1625,6 +1625,9 @@ public class PluginAppletViewer extends XEmbeddedFrame
appletShutdown(p);
appletPanels.removeElement(p);
+
+ // Mark classloader unusable
+ ((JNLPClassLoader) cl).decrementLoaderUseCount();
try {
SwingUtilities.invokeAndWait(new Runnable() {