changeset 1971:9e75f57aae29

Force Event Dispatch Thread to always get created so its contextclassloader will be set properly. Also made a minor update to reflect related bug number to a previous commit made.
author Man Lung Wong <mwong@redhat.com>
date Fri, 30 Jul 2010 16:06:02 -0400
parents 08baa34da100
children c5c7cfebb101
files ChangeLog rt/net/sourceforge/jnlp/Launcher.java rt/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java
diffstat 3 files changed, 20 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Jul 29 17:26:39 2010 -0400
+++ b/ChangeLog	Fri Jul 30 16:06:02 2010 -0400
@@ -1,3 +1,15 @@
+2010-07-30  Man Lung Wong  <mwong@redhat.com>
+	* netx/net/sourceforge/jnlp/Launcher.java
+	(launchApplication): Make sure an Event Dispatch Thread
+	is created before contextclassloader gets set.
+	* netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java
+	(ContextUpdater): Removed it as it is no longer useful after
+	the above change.
+	(checkTopLevelWindow): Removed the line that adds
+	ContextUpdater as it no longer exists.
+	* NEWS: This fixes one of the problems launching the link
+	mention in icedtea bug 486.
+
 2010-07-29  Omair Majid  <omajid@redhat.com>
 
 	* NEWS: Add this fix.
@@ -311,6 +323,7 @@
 	be parsed with the encoding the jnlp file is in.
     (getEncoding): A new method which checks the first four bytes of input
 	and determines what the files encoding is.
+	* NEWS: Fixes icedtea bug 486.
 
 2010-06-29  Omair Majid <omajid@redhat.com>
 
--- a/rt/net/sourceforge/jnlp/Launcher.java	Thu Jul 29 17:26:39 2010 -0400
+++ b/rt/net/sourceforge/jnlp/Launcher.java	Fri Jul 30 16:06:02 2010 -0400
@@ -42,6 +42,8 @@
 import net.sourceforge.jnlp.services.ServiceUtil;
 import net.sourceforge.jnlp.util.Reflect;
 
+import javax.swing.SwingUtilities;
+
 /**
  * Launches JNLPFiles either in the foreground or background.<p>
  *
@@ -441,6 +443,11 @@
 
             Method main = mainClass.getDeclaredMethod("main", new Class[] {String[].class} );
             String args[] = file.getApplication().getArguments();
+            
+            SwingUtilities.invokeAndWait(new Runnable() {
+                // dummy method to force Event Dispatch Thread creation
+                public void run(){}
+            });
 
             setContextClassLoaderForAllThreads(app.getThreadGroup(), app.getClassLoader());
 
--- a/rt/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java	Thu Jul 29 17:26:39 2010 -0400
+++ b/rt/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java	Fri Jul 30 16:06:02 2010 -0400
@@ -104,43 +104,9 @@
     /** weak reference to most app who's windows was most recently activated */
     private WeakReference activeApplication = null;
 
-    /** listener installs the app's classloader on the event dispatch thread */
-    private ContextUpdater contextListener = new ContextUpdater();
-    
     /** Sets whether or not exit is allowed (in the context of the plugin, this is always false) */
     private boolean exitAllowed = true;
 
-    private class ContextUpdater extends WindowAdapter implements PrivilegedAction {
-        private ApplicationInstance app = null;
-
-        public void windowActivated(WindowEvent e) {
-            app = getApplication(e.getWindow());
-            AccessController.doPrivileged(this);
-            app = null;
-        }
-
-        public Object run() {
-            if (app != null) {
-                Thread.currentThread().setContextClassLoader(app.getClassLoader());
-                activeApplication = new WeakReference(app);
-            }
-            else
-                Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
-
-            return null;
-        }
-
-        public void windowDeactivated(WindowEvent e) {
-            activeApplication = null;
-        }
-
-        public void windowClosing(WindowEvent e) {
-        	System.err.println("Disposing window");
-        	e.getWindow().dispose();
-        }
-    };
-
-
     /**
      * Creates a JNLP SecurityManager.
      */
@@ -462,8 +428,6 @@
             weakWindows.add(window); // for mapping window -> app
             weakApplications.add(app);
 
-            w.addWindowListener(contextListener); // for dynamic context classloader
-
             app.addWindow(w);
         }