/hg/icedtea-web: BasicService code does not work when placed in ...

ddadacha at icedtea.classpath.org ddadacha at icedtea.classpath.org
Mon Dec 19 12:01:10 PST 2011


changeset 221174bcd4ec in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=221174bcd4ec
author: Danesh Dadachanji <ddadacha at redhat.com>
date: Mon Dec 19 15:00:03 2011 -0500

	BasicService code does not work when placed in the applet
	constructor.


diffstat:

 ChangeLog                                             |  11 +++++++++++
 netx/net/sourceforge/jnlp/Launcher.java               |  19 ++++++++++---------
 netx/net/sourceforge/jnlp/runtime/AppletInstance.java |  14 ++++++++++++++
 3 files changed, 35 insertions(+), 9 deletions(-)

diffs (74 lines):

diff -r 331a58713544 -r 221174bcd4ec ChangeLog
--- a/ChangeLog	Fri Dec 16 12:12:18 2011 -0500
+++ b/ChangeLog	Mon Dec 19 15:00:03 2011 -0500
@@ -1,3 +1,14 @@
+2011-12-19  Danesh Dadachanji <ddadacha at redhat.com>
+
+	Fix for BasicService being used in applet constructors but not 
+	having access to ApplicationInstance variable.
+	* netx/net/sourceforge/jnlp/Launcher.java: 
+	(createApplet): Moved applet initialization below loader.setApplication,
+	appletInstance is now initialized with applet param as null.
+	* netx/net/sourceforge/jnlp/runtime/AppletInstance.java:
+	(setApplet): New method, allows setting of AppletInstance's applet 
+	only once.
+
 2011-12-16  Deepak Bhole <dbhole at redhat.com>
 
 	Patch from Thomas Meyer <thomas at m3y3r.de>
diff -r 331a58713544 -r 221174bcd4ec netx/net/sourceforge/jnlp/Launcher.java
--- a/netx/net/sourceforge/jnlp/Launcher.java	Fri Dec 16 12:12:18 2011 -0500
+++ b/netx/net/sourceforge/jnlp/Launcher.java	Mon Dec 19 15:00:03 2011 -0500
@@ -708,18 +708,19 @@
 
             ThreadGroup group = Thread.currentThread().getThreadGroup();
 
+            AppletInstance appletInstance;
+            if (cont == null)
+                appletInstance = new AppletInstance(file, group, loader, null);
+            else
+                appletInstance = new AppletInstance(file, group, loader, null, cont);
+
+            loader.setApplication(appletInstance);
+
             String appletName = file.getApplet().getMainClass();
             Class appletClass = loader.loadClass(appletName);
             Applet applet = (Applet) appletClass.newInstance();
-
-            AppletInstance appletInstance;
-            if (cont == null)
-                appletInstance = new AppletInstance(file, group, loader, applet);
-            else
-                appletInstance = new AppletInstance(file, group, loader, applet, cont);
-
-            loader.setApplication(appletInstance);
-
+            appletInstance.setApplet(applet);
+            
             setContextClassLoaderForAllThreads(appletInstance.getThreadGroup(), appletInstance.getClassLoader());
 
             return appletInstance;
diff -r 331a58713544 -r 221174bcd4ec netx/net/sourceforge/jnlp/runtime/AppletInstance.java
--- a/netx/net/sourceforge/jnlp/runtime/AppletInstance.java	Fri Dec 16 12:12:18 2011 -0500
+++ b/netx/net/sourceforge/jnlp/runtime/AppletInstance.java	Mon Dec 19 15:00:03 2011 -0500
@@ -52,6 +52,20 @@
     }
 
     /**
+     * Set the applet of this launched application; can only be called once.
+     */
+    public void setApplet(Applet applet) {
+        if (this.applet != null) {
+            if (JNLPRuntime.isDebug()) {
+                Exception ex = new IllegalStateException("Applet can only be set once.");
+                ex.printStackTrace();
+            }
+            return;
+        }
+        this.applet = applet;
+    }
+
+    /**
      *
      */
     public AppletInstance(JNLPFile file, ThreadGroup group, ClassLoader loader, Applet applet, Container cont) {



More information about the distro-pkg-dev mailing list