changeset 178:331d5d580cc4

Fixed classloader sharing rules for applets
author Deepak Bhole <dbhole@redhat.com>
date Mon, 28 Mar 2011 13:41:16 -0400
parents d94fc0fb8a53
children c04136b79d4a
files ChangeLog netx/net/sourceforge/jnlp/PluginBridge.java
diffstat 2 files changed, 34 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Mar 25 14:23:28 2011 -0400
+++ b/ChangeLog	Mon Mar 28 13:41:16 2011 -0400
@@ -1,3 +1,10 @@
+2011-03-28  Deepak Bhole <dbhole@redhat.com>
+
+	* netx/net/sourceforge/jnlp/PluginBridge.java
+	(PluginBridge): Construct unique key based on a combination of
+	codebase, cache_archive, java_archive, and archive. This automatically
+	ensures are loaders are shared only when appropriate.
+
 2011-03-25  Denis Lila <dlila@redhat.com>
 
 	* netx/net/sourceforge/jnlp/PluginBridge.java
--- a/netx/net/sourceforge/jnlp/PluginBridge.java	Fri Mar 25 14:23:28 2011 -0400
+++ b/netx/net/sourceforge/jnlp/PluginBridge.java	Mon Mar 28 13:41:16 2011 -0400
@@ -132,10 +132,33 @@
         else
             security = null;
 
-        // Plugin needs to share classloaders so that applet instances from 
-        // same page can communicate (there are applets known to require 
-        // such communication for proper functionality)
-        this.uniqueKey = documentBase.toString();
+        /* According to http://download.oracle.com/javase/6/docs/technotes/guides/deployment/deployment-guide/applet-compatibility.html, 
+         * classloaders are shared iff these properties match:
+         * codebase, cache_archive, java_archive, archive
+         * 
+         * To achieve this, we create the uniquekey based on those 4 values,
+         * always in the same order. The initial "<NAME>=" parts ensure a 
+         * bad tag cannot trick the loader into getting shared with another.
+         */
+
+        // Firefox sometimes skips the codebase if it is default  -- ".", 
+        // so set it that way if absent
+        String codebaseAttr =      atts.get("codebase") != null ?
+                                   atts.get("codebase") : ".";
+
+        String cache_archiveAttr = atts.get("cache_archive") != null ? 
+                                   atts.get("cache_archive") : "";
+
+        String java_archiveAttr =  atts.get("java_archive") != null ? 
+                                   atts.get("java_archive") : "";
+
+        String archiveAttr =       atts.get("archive") != null ? 
+                                   atts.get("archive") : "";
+
+        this.uniqueKey = "codebase=" + codebaseAttr +
+                         "cache_archive=" + cache_archiveAttr + 
+                         "java_archive=" + java_archiveAttr + 
+                         "archive=" +  archiveAttr;
 
         usePack = false;
         useVersion = false;