changeset in /hg/icedtea: 2008-04-08 Joshua Sumali <jsumali at re...

Joshua Sumali jsumali at redhat.com
Thu May 29 14:12:58 PDT 2008


changeset 8f5c92edd931 in /hg/icedtea
details: http://icedtea.classpath.org/hg/icedtea?cmd=changeset;node=8f5c92edd931
description:
	2008-04-08  Joshua Sumali  <jsumali at redhat.com>

	        * generated/sun/awt/X11/generator/sizer.32: Regenerated.
	        * patches/icedtea-webservices.patch: Relaxed visiblity a bit more in
	        sun.applet.AppletPanel for NetxPanel.
	        * rt/net/sourceforge/jnlp/Launcher.java
	        (getApplet(file, enableCodeBase, container)): New method.
	        (createAppletObject(file, enableCodeBase, container)): Likewise.
	        * rt/net/sourceforge/jnlp/NetxPanel.java: Removed run() and replaced with
	        new method runLoader().
	        * rt/net/sourceforge/jnlp/PluginBridge.java: Refactored.
	        (isApplet): New method.
	        (isApplication): Likewise.
	        (isComponent): Likewise.
	        (isInstaller): Likewise.
	        * rt/net/sourceforge/jnlp/resources/Messages.properties: Added message for
	        network access.
	        * rt/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
	        (runtimePermissions): New field.
	        (setSecurity): New method.
	        (addPermission(perm)): Likewise.
	        (getSecurity): Likewise.
	        * rt/net/sourceforge/jnlp/runtime/JNLPPolicy.java: Check runtime
	        permissions for permissions that may have been granted by the user.
	        (implies): New method.
	        * rt/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java: Catch socket
	        permission requests, and ask user for permission when application is
	        unsigned.
	        (askPermission(perm)): New method.
	        (addPermission(perm)): Likewise.
	        * rt/net/sourceforge/jnlp/security/SecurityWarningDialog.java: Add NETWORK
	        type access, and allow passing of parameters for message dialogs.
	        (showAccessWarningDialogs(accessType, file, extras)): New method.
	        * rt/net/sourceforge/jnlp/services/ServiceUtil.java
	        (checkAccess(type, extras)): New method.

diffstat:

11 files changed, 610 insertions(+), 393 deletions(-)
ChangeLog                                                   |   36 +
patches/icedtea-webservices.patch                           |   70 ++-
rt/net/sourceforge/jnlp/Launcher.java                       |   99 +++-
rt/net/sourceforge/jnlp/NetxPanel.java                      |  169 ++-----
rt/net/sourceforge/jnlp/PluginBridge.java                   |  245 ++++-------
rt/net/sourceforge/jnlp/resources/Messages.properties       |    1 
rt/net/sourceforge/jnlp/runtime/JNLPClassLoader.java        |   54 ++
rt/net/sourceforge/jnlp/runtime/JNLPPolicy.java             |   18 
rt/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java    |  135 ++++--
rt/net/sourceforge/jnlp/security/SecurityWarningDialog.java |  140 +++---
rt/net/sourceforge/jnlp/services/ServiceUtil.java           |   36 +

diffs (truncated from 1393 to 500 lines):

diff -r ff3d152968b5 -r 8f5c92edd931 ChangeLog
--- a/ChangeLog	Tue Apr 08 08:55:33 2008 +0100
+++ b/ChangeLog	Tue Apr 08 09:37:00 2008 -0400
@@ -1,3 +1,39 @@ 2008-04-08  Andrew John Hughes  <gnu_and
+2008-04-08  Joshua Sumali  <jsumali at redhat.com>
+
+	* generated/sun/awt/X11/generator/sizer.32: Regenerated.
+	* patches/icedtea-webservices.patch: Relaxed visiblity a bit more in
+	sun.applet.AppletPanel for NetxPanel.
+	* rt/net/sourceforge/jnlp/Launcher.java
+	(getApplet(file, enableCodeBase, container)): New method.
+	(createAppletObject(file, enableCodeBase, container)): Likewise.
+	* rt/net/sourceforge/jnlp/NetxPanel.java: Removed run() and replaced with
+	new method runLoader().
+	* rt/net/sourceforge/jnlp/PluginBridge.java: Refactored.
+	(isApplet): New method.
+	(isApplication): Likewise.
+	(isComponent): Likewise.
+	(isInstaller): Likewise.
+	* rt/net/sourceforge/jnlp/resources/Messages.properties: Added message for
+	network access.
+	* rt/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
+	(runtimePermissions): New field.
+	(setSecurity): New method.
+	(addPermission(perm)): Likewise.
+	(getSecurity): Likewise.
+	* rt/net/sourceforge/jnlp/runtime/JNLPPolicy.java: Check runtime
+	permissions for permissions that may have been granted by the user.
+	(implies): New method.
+	* rt/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java: Catch socket
+	permission requests, and ask user for permission when application is
+	unsigned.
+	(askPermission(perm)): New method.
+	(addPermission(perm)): Likewise.
+	* rt/net/sourceforge/jnlp/security/SecurityWarningDialog.java: Add NETWORK
+	type access, and allow passing of parameters for message dialogs.
+	(showAccessWarningDialogs(accessType, file, extras)): New method.
+	* rt/net/sourceforge/jnlp/services/ServiceUtil.java
+	(checkAccess(type, extras)): New method.
+
 2008-04-08  Andrew John Hughes  <gnu_andrew at member.fsf.org>
 
 	* Makefile.am: Add NO_DOCS option as
diff -r ff3d152968b5 -r 8f5c92edd931 generated/sun/awt/X11/generator/sizer.32
Binary file generated/sun/awt/X11/generator/sizer.32 has changed
diff -r ff3d152968b5 -r 8f5c92edd931 patches/icedtea-webservices.patch
--- a/patches/icedtea-webservices.patch	Tue Apr 08 08:55:33 2008 +0100
+++ b/patches/icedtea-webservices.patch	Tue Apr 08 09:37:00 2008 -0400
@@ -10,27 +10,6 @@ diff -urN openjdk.orig/jdk/make/launcher
  $(call make-launcher, orbd, com.sun.corba.se.impl.activation.ORBD, \
    -J-Dcom.sun.CORBA.activation.DbDir=./orb.db \
    -J-Dcom.sun.CORBA.activation.Port=1049 \
-diff -urN openjdk.orig/jdk/src/share/classes/sun/applet/AppletPanel.java openjdk/jdk/src/share/classes/sun/applet/AppletPanel.java
---- openjdk.orig/jdk/src/share/classes/sun/applet/AppletPanel.java	2008-01-12 15:53:45.000000000 -0500
-+++ openjdk/jdk/src/share/classes/sun/applet/AppletPanel.java	2008-01-14 15:00:08.000000000 -0500
-@@ -68,7 +68,7 @@
-     /**
-      * The applet (if loaded).
-      */
--    Applet applet;
-+    protected Applet applet;
- 
-     /**
-      * Applet will allow initialization.  Should be
-@@ -306,7 +306,7 @@
-     /**
-      * Get an event from the queue.
-      */
--    synchronized AppletEvent getNextEvent() throws InterruptedException {
-+    protected synchronized AppletEvent getNextEvent() throws InterruptedException {
-         while (queue == null || queue.isEmpty()) {
-             wait();
-         }
 diff -urN openjdk.orig/jdk/src/share/classes/sun/applet/AppletViewerPanel.java openjdk/jdk/src/share/classes/sun/applet/AppletViewerPanel.java
 --- openjdk.orig/jdk/src/share/classes/sun/applet/AppletViewerPanel.java	2008-01-12 15:53:45.000000000 -0500
 +++ openjdk/jdk/src/share/classes/sun/applet/AppletViewerPanel.java	2008-02-04 11:51:20.000000000 -0500
@@ -1371,3 +1350,52 @@ diff -ruN openjdk.orig/jdk/src/share/cla
 +	}
 +    }
 +}
+--- openjdk-clean/jdk/src/share/classes/sun/applet/AppletPanel.java	2008-03-26 04:58:12.000000000 -0400
++++ openjdk/jdk/src/share/classes/sun/applet/AppletPanel.java	2008-04-07 21:55:56.000000000 -0400
+@@ -68,7 +68,7 @@
+     /**
+      * The applet (if loaded).
+      */
+-    Applet applet;
++    protected Applet applet;
+ 
+     /**
+      * Applet will allow initialization.  Should be
+@@ -117,7 +117,7 @@
+     /**
+      * The thread for the applet.
+      */
+-    Thread handler;
++    protected Thread handler;
+ 
+ 
+     /**
+@@ -162,7 +162,8 @@
+      * Creates a thread to run the applet. This method is called
+      * each time an applet is loaded and reloaded.
+      */
+-    synchronized void createAppletThread() {
++	//Overridden by NetxPanel.
++    protected synchronized void createAppletThread() {
+         // Create a thread group for the applet, and start a new
+         // thread to load the applet.
+         String nm = "applet-" + getCode();
+@@ -306,7 +307,7 @@
+     /**
+      * Get an event from the queue.
+      */
+-    synchronized AppletEvent getNextEvent() throws InterruptedException {
++    protected synchronized AppletEvent getNextEvent() throws InterruptedException {
+         while (queue == null || queue.isEmpty()) {
+             wait();
+         }
+@@ -695,7 +696,8 @@
+      * applet event processing so that it can be gracefully interrupted from
+      * things like HotJava.
+      */
+-    private void runLoader() {
++	//Overridden by NetxPanel.
++    protected void runLoader() {
+         if (status != APPLET_DISPOSE) {
+             showAppletStatus("notdisposed");
+             return;
diff -r ff3d152968b5 -r 8f5c92edd931 rt/net/sourceforge/jnlp/Launcher.java
--- a/rt/net/sourceforge/jnlp/Launcher.java	Tue Apr 08 08:55:33 2008 +0100
+++ b/rt/net/sourceforge/jnlp/Launcher.java	Tue Apr 08 09:37:00 2008 -0400
@@ -21,8 +21,6 @@ import java.awt.Container;
 import java.awt.Container;
 import java.io.*;
 import java.net.*;
-import java.util.*;
-import java.security.*;
 import java.lang.reflect.*;
 
 import net.sourceforge.jnlp.cache.*;
@@ -157,10 +155,12 @@ public class Launcher {
     public ApplicationInstance launch(JNLPFile file, Container cont) throws LaunchException {
         TgThread tg;
 
-        if (cont == null)
-          tg = new TgThread(file);
+        if (file instanceof PluginBridge && cont != null)
+        	tg = new TgThread(file, cont, true);
+        else if (cont == null)
+        	tg = new TgThread(file);
         else
-          tg = new TgThread(file, cont);
+        	tg = new TgThread(file, cont);
 
         tg.start();
 
@@ -357,11 +357,30 @@ public class Launcher {
             throw launchError(new LaunchException(file, null, R("LSFatal"), R("LCClient"), R("LNotApplet"), R("LNotAppletInfo")));
 
         try {
-            AppletInstance applet= createApplet(file, enableCodeBase, cont);
+            AppletInstance applet = createApplet(file, enableCodeBase, cont);
             applet.initialize();
-
+            
             applet.getAppletEnvironment().startApplet(); // this should be a direct call to applet instance
-
+            return applet;
+        }
+        catch (LaunchException lex) {
+            throw launchError(lex);
+        }
+        catch (Exception ex) {
+            throw launchError(new LaunchException(file, ex, R("LSFatal"), R("LCLaunching"), R("LCouldNotLaunch"), R("LCouldNotLaunchInfo")));
+        }
+    }
+    
+    /**
+     * Gets an ApplicationInstance, but does not launch the applet.
+     */
+    protected ApplicationInstance getApplet(JNLPFile file, boolean enableCodeBase, Container cont) throws LaunchException {
+        if (!file.isApplet())
+            throw launchError(new LaunchException(file, null, R("LSFatal"), R("LCClient"), R("LNotApplet"), R("LNotAppletInfo")));
+
+        try {
+            AppletInstance applet = createApplet(file, enableCodeBase, cont);
+            applet.initialize();
             return applet;
         }
         catch (LaunchException lex) {
@@ -418,7 +437,34 @@ public class Launcher {
         }
     }
 
-
+    /**
+     * Creates an Applet object from a JNLPFile. This is mainly to be used with
+     * gcjwebplugin.
+     * @param file the PluginBridge to be used.
+     * @param enableCodeBase whether to add the code base URL to the classloader.
+     */
+    protected Applet createAppletObject(JNLPFile file, boolean enableCodeBase, Container cont) throws LaunchException {
+        try {
+            JNLPClassLoader loader = JNLPClassLoader.getInstance(file, updatePolicy);
+
+            if (enableCodeBase || file.getResources().getJARs().length == 0)
+                loader.enableCodeBase();
+
+            String appletName = file.getApplet().getMainClass();
+
+			//Classloader chokes if there's '/' in the path to the main class.
+			//Must replace with '.' instead.
+			appletName = appletName.replace('/', '.');
+            Class appletClass = loader.loadClass(appletName);
+            Applet applet = (Applet) appletClass.newInstance();
+
+            return applet;
+        }
+        catch (Exception ex) {
+            throw launchError(new LaunchException(file, ex, R("LSFatal"), R("CLInit"), R("LInitApplet"), R("LInitAppletInfo")));
+        }
+    }
+    
     /**
      * Creates an Application.
      */
@@ -483,6 +529,7 @@ public class Launcher {
         private ApplicationInstance application;
         private LaunchException exception;
         private Container cont;
+        private boolean isPlugin = false;
 
         TgThread(JNLPFile file) {
             this(file, null);
@@ -493,21 +540,34 @@ public class Launcher {
 
             this.file = file;
             this.cont = cont;
+        }
+        
+        TgThread(JNLPFile file, Container cont, boolean isPlugin) {
+            super(createThreadGroup(file), file.getTitle());
+            this.file = file;
+            this.cont = cont;
+            this.isPlugin = isPlugin;
         }
 
         public void run() {
             try {
                 if (context)
-                    new Reflect().invokeStatic("sun.awt.SunToolkit", "createNewAppContext");
-
-                if (file.isApplication())
-                    application = launchApplication(file);
-                else if (file.isApplet())
-                    application = launchApplet(file, true, cont); // enable applet code base
-                else if (file.isInstaller())
-                    application = launchInstaller(file);
-                else 
-                    throw launchError(new LaunchException(file, null, R("LSFatal"), R("LCClient"), R("LNotLaunchable"), R("LNotLaunchableInfo")));
+                	new Reflect().invokeStatic("sun.awt.SunToolkit", "createNewAppContext");
+
+                if (isPlugin) {
+                	application = getApplet(file, true, cont);
+                } else {
+                	if (file.isApplication())
+                		application = launchApplication(file);
+                	else if (file.isApplet())
+                		application = launchApplet(file, true, cont); // enable applet code base
+                	else if (file.isInstaller())
+                		application = launchInstaller(file);
+                	else 
+                		throw launchError(new LaunchException(file, null, 
+                				R("LSFatal"), R("LCClient"), R("LNotLaunchable"), 
+                				R("LNotLaunchableInfo")));
+                }
             }
             catch (LaunchException ex) {
                 exception = ex;
@@ -521,6 +581,7 @@ public class Launcher {
         public ApplicationInstance getApplication() {
             return application;
         }
+        
     };
 
 
diff -r ff3d152968b5 -r 8f5c92edd931 rt/net/sourceforge/jnlp/NetxPanel.java
--- a/rt/net/sourceforge/jnlp/NetxPanel.java	Tue Apr 08 08:55:33 2008 +0100
+++ b/rt/net/sourceforge/jnlp/NetxPanel.java	Tue Apr 08 09:37:00 2008 -0400
@@ -27,7 +27,8 @@ import net.sourceforge.jnlp.runtime.JNLP
 
 import java.net.URL;
 import java.util.Hashtable;
-import sun.applet.*;
+
+import sun.applet.AppletViewerPanel;
 
 /**
  * This panel calls into netx to run an applet, and pipes the display
@@ -44,116 +45,68 @@ public class NetxPanel extends AppletVie
         super(documentURL, atts);
     }
 
-    public void run()
-    {
-        Thread curThread = Thread.currentThread();
-        boolean disposed = false;
-        while (!disposed && !curThread.isInterrupted()) {
-            AppletEvent evt;
-            try {
-                evt = getNextEvent();
-            } catch (InterruptedException e) {
-                showAppletStatus("bail");
-                return;
-            }
+    //Overriding to use Netx classloader. You might need to relax visibility
+    //in sun.applet.AppletPanel for runLoader().
+    protected void runLoader() {
 
-            try {
-                switch (evt.getID()) {
-                  case APPLET_LOAD:
-	          case APPLET_INIT:
-                      // TODO: split out the load/init/start steps in Netx
-                      break;
+    	try {
+    		bridge = new PluginBridge(baseURL, 
+    				getDocumentBase(),
+    				getJarFiles(), 
+    				getCode(),
+    				getWidth(), 
+    				getHeight(), 
+    				atts);
+    		
+    		//The custom NetX Policy and SecurityManager are set here.
+    		if (!JNLPRuntime.isInitialized()) {
+    			System.out.println("initializing JNLPRuntime...");
+    			JNLPRuntime.initialize();
+    		} else {
+    			System.out.println("JNLPRuntime already initialized");
+    		}
 
-                  case APPLET_START:
-                      // FIXME: in sun.applet.AppletPanel, the validation and running
-                      // of the applet all happen in the event dispatch thread.  Need
-                      // to carefully audit what they do and where, and see if we need
-                      // to do the same here or in netx code.
+    		doInit = true;
+    		dispatchAppletEvent(APPLET_LOADING, null);
+    		status = APPLET_LOAD;
+    		
+    		//FIXME: For some reason, when this applet is loaded by NetX, 
+    		//keyboard input will not make it to the applet when displayed in
+    		//firefox, unless a mouse button is held down.
+    		Launcher l = new Launcher();
+    		AppletInstance appInst = (AppletInstance) l.launch(bridge, this);
+    		applet = appInst.getApplet();
+    		
+    		//On the other hand, if you create an applet this way, it'll work
+    		//fine. Note that you might to open visibility in sun.applet.AppletPanel
+    		//for this to work (the loader field, and getClassLoader).
+    		//loader = getClassLoader(getCodeBase(), getClassLoaderCacheKey());
+    		//applet = createApplet(loader);
+    		
+    		// This shows that when using NetX's JNLPClassLoader, keyboard input
+    		// won't make it to the applet, whereas using sun.applet.AppletClassLoader
+    		// works just fine.
+    		
+    		dispatchAppletEvent(APPLET_LOADING_COMPLETED, null);
 
-                      bridge = new PluginBridge(baseURL,
-                                                getDocumentBase(),
-                                                getJarFiles(),
-                                                getCode(),
-                                                getWidth(), getHeight(),
-                                                atts);
-
-                      if (! JNLPRuntime.isInitialized())
-                          JNLPRuntime.initialize();
-
-                      Launcher l = new Launcher();
-                      dispatchAppletEvent(APPLET_LOADING_COMPLETED, null); // not quite..
-
-                      applet = ((AppletInstance)l.launch(bridge, this)).getApplet();
-
-                      status = APPLET_START;
-                      showAppletStatus("started");
-                      break;
-
-                case APPLET_STOP:
-                    if (status != APPLET_START) {
-                        showAppletStatus("notstarted");
-                        break;
-                    }
-
-                    status = APPLET_STOP;
-
-                    applet.setVisible(false);
-                    applet.stop();
-
-                    showAppletStatus("stopped");
-                    break;
-
-               case APPLET_DESTROY:
-                    if (status != APPLET_STOP && status != APPLET_INIT) {
-                        showAppletStatus("notstopped");
-                        break;
-                    }
-                    status = APPLET_DESTROY;
-
-                    applet.destroy();
-                    showAppletStatus("destroyed");
-                    break;
-
-                case APPLET_DISPOSE:
-                    if (status != APPLET_DESTROY && status != APPLET_LOAD) {
-                        showAppletStatus("notdestroyed");
-                        break;
-                    }
-                    status = APPLET_DISPOSE;
-
-                    remove(applet);
-                    applet = null;
-                    showAppletStatus("disposed");
-                    disposed = true;
-                    break;
-
-                case APPLET_QUIT:
-                    return;
-                }
-            } catch (Exception e) {
-                status = APPLET_ERROR;
-                if (e.getMessage() != null) {
-                    showAppletStatus("exception2", e.getClass().getName(),
-                                     e.getMessage());
-                } else {
-                    showAppletStatus("exception", e.getClass().getName());
-                }
-                showAppletException(e);
-            } catch (ThreadDeath e) {
-                showAppletStatus("death");
-                return;
-            } catch (Error e) {
-                status = APPLET_ERROR;
-                if (e.getMessage() != null) {
-                    showAppletStatus("error2", e.getClass().getName(),
-                                     e.getMessage());
-                } else {
-                    showAppletStatus("error", e.getClass().getName());
-                }
-                showAppletException(e);
-            }
-            clearLoadAbortRequest();
-        }
+    		if (applet != null)
+    		{
+    			// Stick it in the frame
+    			applet.setStub(this);
+    			applet.setVisible(false);
+    			add("Center", applet);
+    			showAppletStatus("loaded");
+    			validate();
+    		}
+    	} catch (Exception e) {
+    		e.printStackTrace();
+    	}
+    }
+    
+    // Reminder: Relax visibility in sun.applet.AppletPanel
+    protected synchronized void createAppletThread() {
+    	handler = new Thread(this);
+    	handler.start();
     }
 
 }
diff -r ff3d152968b5 -r 8f5c92edd931 rt/net/sourceforge/jnlp/PluginBridge.java
--- a/rt/net/sourceforge/jnlp/PluginBridge.java	Tue Apr 08 08:55:33 2008 +0100
+++ b/rt/net/sourceforge/jnlp/PluginBridge.java	Tue Apr 08 09:37:00 2008 -0400
@@ -2,19 +2,19 @@
  * Copyright 2007 Red Hat, Inc.
  * This file is part of IcedTea, http://icedtea.classpath.org
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Sun designates this
  * particular file as subject to the "Classpath" exception as provided
  * by Sun in the LICENSE file that accompanied this code.
- * 
+ *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
- * 
+ *



More information about the distro-pkg-dev mailing list