Mercurial > hg > release > icedtea-web-1.5
changeset 988:006c94731726
Made it works (basicaly) on any JDK (including Added accidentally skipped hunk changeset)
author | Jiri Vanek <jvanek@redhat.com> |
---|---|
date | Thu, 19 Jun 2014 14:29:19 +0200 |
parents | b16b30a1380d |
children | a2ed2390946a |
files | ChangeLog Makefile.am acinclude.m4 configure.ac netx/net/sourceforge/jnlp/NetxPanel.java netx/sun/applet/AppletViewerPanelAccess.java netx/sun/applet/package-info.java plugin/icedteanp/java/sun/applet/PluginAppletPanelFactory.java plugin/icedteanp/java/sun/applet/PluginAppletViewer.java |
diffstat | 9 files changed, 251 insertions(+), 51 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Thu Jun 19 13:05:26 2014 +0200 +++ b/ChangeLog Thu Jun 19 14:29:19 2014 +0200 @@ -1,3 +1,29 @@ +2014-06-19 Jiri Vanek <jvanek@redhat.com> + + Made it works (basicaly) on any JDK + * Makefile.am: (NETX_PKGS) sun.applet added to recognized netx packages + (netx-dist.stamp) sun directory included into packed list + * acinclude.m4: removed (IT_CHECK_FOR_APPLETVIEWERPANEL_HOLE) check. Added + IT_CHECK_FOR_SUN_APPLET_ACCESSIBILITY, which test existence of + classes sun.applet.AppletPanel, sun.applet.AppletViewerPanel + fields applet, documentURL, baseURL and methods run and runLoader. Addapted messge + * configure.ac: call to IT_CHECK_FOR_APPLETVIEWERPANEL_HOLE replaced by call + to IT_CHECK_FOR_SUN_APPLET_ACCESSIBILITY + * /netx/net/sourceforge/jnlp/NetxPanel.java: now extends AppletViewerPanelAccess + instead of AppletViewerPanel directly. Access to baseURL, applet and documentURL + replaced by dedicated getters/setters + * netx/sun/applet/AppletViewerPanelAccess.java: new class extending AppletViewerPanel + and enabling access to applet, documentURL and baseURL. Backed by reflection. + Also overriding run by usage of short copypasted code. + * netx/sun/applet/AppletViewerPanelAccess.java: addedd accidentally skipped + createAppletThread method + * netx/sun/applet/package-info.java: new file with worning about usage of this + package in itw + * plugin/icedteanp/java/sun/applet/PluginAppletPanelFactory.java: only call + to super debug repalced by ITW's debugging call + * plugin/icedteanp/java/sun/applet/PluginAppletViewer.java: used getters as in + NetxPanel + 2014-06-19 Kurt Miller <kurt@intricatesoftware.com> Fixed PR1743 - Intermittant deadlock in PluginRequestProcessor
--- a/Makefile.am Thu Jun 19 13:05:26 2014 +0200 +++ b/Makefile.am Thu Jun 19 14:29:19 2014 +0200 @@ -135,7 +135,8 @@ net.sourceforge.jnlp.controlpanel net.sourceforge.jnlp.event \ net.sourceforge.jnlp.runtime net.sourceforge.jnlp.security \ net.sourceforge.jnlp.security.viewer net.sourceforge.jnlp.services \ - net.sourceforge.jnlp.tools net.sourceforge.jnlp.util + net.sourceforge.jnlp.tools net.sourceforge.jnlp.util \ + sun.applet NETX_EXCLUDE_SRCS= @@ -505,11 +506,11 @@ (cd $(NETX_DIR) ; \ mkdir -p lib ; \ $(BOOT_DIR)/bin/jar cfm lib/classes.jar \ - $(abs_top_builddir)/netx.manifest javax/jnlp net ; \ + $(abs_top_builddir)/netx.manifest javax/jnlp net sun; \ cp -pPR $(SRC_DIR_LINK) $(NETX_SRCDIR) src; \ find src -type f -exec chmod 640 '{}' ';' -o -type d -exec chmod 750 '{}' ';'; \ cd src ; \ - $(ZIP) -qr $(NETX_DIR)/lib/src.zip javax net ) + $(ZIP) -qr $(NETX_DIR)/lib/src.zip javax net sun) mkdir -p stamps touch $@
--- a/acinclude.m4 Thu Jun 19 13:05:26 2014 +0200 +++ b/acinclude.m4 Thu Jun 19 14:29:19 2014 +0200 @@ -852,38 +852,29 @@ dnl Checks that sun.applet.AppletViewerPanel is available dnl and public (via the patch in IcedTea6, applet_hole.patch) dnl Can be removed when that is upstream or unneeded -AC_DEFUN([IT_CHECK_FOR_APPLETVIEWERPANEL_HOLE],[ +AC_DEFUN([IT_CHECK_FOR_SUN_APPLET_ACCESSIBILITY],[ AC_REQUIRE([IT_FIND_JAVAC]) AC_REQUIRE([IT_FIND_JAVA]) -AC_CACHE_CHECK([if sun.applet.AppletViewerPanel is available and public], it_cv_applet_hole, [ +AC_CACHE_CHECK([if selected classes, fields and methods from sun.applet are accessible via reflection], it_cv_applet_hole, [ CLASS=TestAppletViewer.java BYTECODE=$(echo $CLASS|sed 's#\.java##') mkdir -p tmp.$$ cd tmp.$$ cat << \EOF > $CLASS [/* [#]line __oline__ "configure" */ -import java.lang.reflect.Modifier; +import java.lang.reflect.*; public class TestAppletViewer { - public static void main(String[] args) + public static void main(String[] args) throws Exception { - try - { - Class<?> clazz = Class.forName("sun.applet.AppletViewerPanel"); - if (Modifier.isPublic(clazz.getModifiers())) - { - System.err.println("Found public sun.applet.AppletViewerPanel"); - System.exit(0); - } - System.err.println("Found non-public sun.applet.AppletViewerPanel"); - System.exit(2); - } - catch (ClassNotFoundException e) - { - System.err.println("Could not find sun.applet.AppletViewerPanel"); - System.exit(1); - } + Class<?> ap = Class.forName("sun.applet.AppletPanel"); + Class<?> avp = Class.forName("sun.applet.AppletViewerPanel"); + Field f1 = ap.getDeclaredField("applet"); + Field f2 = avp.getDeclaredField("documentURL"); + Method m1 = ap.getDeclaredMethod("run"); + Method m2 = ap.getDeclaredMethod("runLoader"); + Field f3 = avp.getDeclaredField("baseURL"); } } ] @@ -892,21 +883,17 @@ if $JAVA -classpath . $BYTECODE >&AS_MESSAGE_LOG_FD 2>&1; then it_cv_applet_hole=yes; else - it_cv_applet_hole=$?; + it_cv_applet_hole=no; fi else - it_cv_applet_hole=3; + it_cv_applet_hole=no; fi ]) rm -f $CLASS *.class cd .. rmdir tmp.$$ -if test x"${it_cv_applet_hole}" = "x1"; then - AC_MSG_ERROR([sun.applet.AppletViewerPanel is not available.]) -elif test x"${it_cv_applet_hole}" = "x2"; then - AC_MSG_ERROR([sun.applet.AppletViewerPanel is not public.]) -elif test x"${it_cv_applet_hole}" = "x3"; then - AC_MSG_ERROR([Compilation failed. See config.log.]) +if test x"${it_cv_applet_hole}" = "xno"; then + AC_MSG_ERROR([Some of the checked items is not avaiable. Check logs.]) fi AC_PROVIDE([$0])dnl ])
--- a/configure.ac Thu Jun 19 13:05:26 2014 +0200 +++ b/configure.ac Thu Jun 19 14:29:19 2014 +0200 @@ -84,7 +84,7 @@ IT_CHECK_FOR_CLASS(SUN_MISC_REF, [sun.misc.Ref]) IT_CHECK_FOR_CLASS(COM_SUN_JNDI_TOOLKIT_URL_URLUTIL, [com.sun.jndi.toolkit.url.UrlUtil]) IT_CHECK_FOR_CLASS(SUN_APPLET_APPLETIMAGEREF, [sun.applet.AppletImageRef]) -IT_CHECK_FOR_APPLETVIEWERPANEL_HOLE +IT_CHECK_FOR_SUN_APPLET_ACCESSIBILITY IT_CHECK_GLIB_VERSION IT_CHECK_XULRUNNER_MIMEDESCRIPTION_CONSTCHAR IT_CHECK_XULRUNNER_REQUIRES_C11
--- a/netx/net/sourceforge/jnlp/NetxPanel.java Thu Jun 19 13:05:26 2014 +0200 +++ b/netx/net/sourceforge/jnlp/NetxPanel.java Thu Jun 19 14:29:19 2014 +0200 @@ -35,7 +35,7 @@ import net.sourceforge.jnlp.splashscreen.SplashUtils; import net.sourceforge.jnlp.util.logging.OutputController; -import sun.applet.AppletViewerPanel; +import sun.applet.AppletViewerPanelAccess; import sun.awt.SunToolkit; /** @@ -44,7 +44,7 @@ * * @author Francis Kung <fkung@redhat.com> */ -public class NetxPanel extends AppletViewerPanel implements SplashController { +public class NetxPanel extends AppletViewerPanelAccess implements SplashController { private final PluginParameters parameters; private PluginBridge bridge = null; private AppletInstance appInst = null; @@ -76,7 +76,7 @@ String uniqueKey = params.getUniqueKey(getCodeBase()); synchronized(TGMapMutex) { if (!uKeyToTG.containsKey(uniqueKey)) { - ThreadGroup tg = new ThreadGroup(Launcher.mainGroup, this.documentURL.toString()); + ThreadGroup tg = new ThreadGroup(Launcher.mainGroup, this.getDocumentURL().toString()); uKeyToTG.put(uniqueKey, tg); } } @@ -95,10 +95,10 @@ //Overriding to use Netx classloader. You might need to relax visibility //in sun.applet.AppletPanel for runLoader(). @Override - protected void runLoader() { + protected void ourRunLoader() { try { - bridge = new PluginBridge(baseURL, + bridge = new PluginBridge(getBaseURL(), getDocumentBase(), getJarFiles(), getCode(), @@ -114,13 +114,13 @@ // May throw LaunchException: appInst = (AppletInstance) l.launch(bridge, this); - applet = appInst.getApplet(); + setApplet(appInst.getApplet()); - if (applet != null) { + if (getApplet() != null) { // Stick it in the frame - applet.setStub(this); - applet.setVisible(false); - add("Center", applet); + getApplet().setStub(this); + getApplet().setVisible(false); + add("Center", getApplet()); showAppletStatus("loaded"); validate(); } @@ -157,7 +157,7 @@ } } - handler = new Thread(getThreadGroup(), this, "NetxPanelThread@" + this.documentURL); + handler = new Thread(getThreadGroup(), this, "NetxPanelThread@" + this.getDocumentURL()); handler.start(); } @@ -213,5 +213,5 @@ public int getSplashHeigth() { return splashController.getSplashHeigth(); } - + }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/netx/sun/applet/AppletViewerPanelAccess.java Thu Jun 19 14:29:19 2014 +0200 @@ -0,0 +1,149 @@ +/* package-info.java + Copyright (C) 2014 Red Hat, Inc. + + This file is part of IcedTea. + + IcedTea is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation, version 2. + + IcedTea 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 for more details. + + You should have received a copy of the GNU General Public License along with + IcedTea; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA. + + Linking this library statically or dynamically with other modules is making a + combined work based on this library. Thus, the terms and conditions of the GNU + General Public License cover the whole combination. + + As a special exception, the copyright holders of this library give you + permission to link this library with independent modules to produce an + executable, regardless of the license terms of these independent modules, and + to copy and distribute the resulting executable under terms of your choice, + provided that you also meet, for each linked independent module, the terms and + conditions of the license of that module. An independent module is a module + which is not derived from or based on this library. If you modify this library, + you may extend this exception to your version of the library, but you are not + obligated to do so. If you do not wish to do so, delete this exception + statement from your version.*/ +package sun.applet; + +import java.applet.Applet; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.net.URL; +import java.util.Hashtable; + +public abstract class AppletViewerPanelAccess extends AppletViewerPanel { + + public AppletViewerPanelAccess(URL documentURL, Hashtable<String, String> atts) { + super(documentURL, atts); + } + + protected URL getDocumentURL() { + try { + Field field = AppletViewerPanel.class.getDeclaredField("documentURL"); + field.setAccessible(true); + return (URL) field.get(this); + } catch (IllegalAccessException ex1) { + throw new RuntimeException(ex1); + } catch (IllegalArgumentException ex2) { + throw new RuntimeException(ex2); + } catch (NoSuchFieldException ex3) { + throw new RuntimeException(ex3); + } catch (SecurityException ex4) { + throw new RuntimeException(ex4); + } + } + + protected void setApplet(Applet iapplet) { + try { + Field field = AppletPanel.class.getDeclaredField("applet"); + field.setAccessible(true); + field.set(this, iapplet); + } catch (IllegalAccessException ex1) { + throw new RuntimeException(ex1); + } catch (IllegalArgumentException ex2) { + throw new RuntimeException(ex2); + } catch (NoSuchFieldException ex3) { + throw new RuntimeException(ex3); + } catch (SecurityException ex4) { + throw new RuntimeException(ex4); + } + } + + @Override + public void run() { + // this is copypasted chunk from AppletPanel.run (the only current + // call of runLoader). Pray it do not change + Thread curThread = Thread.currentThread(); + if (curThread == loaderThread) { + ourRunLoader(); + return; + } + + super.run(); + } + + /** + * NOTE. We cannot override private method, and this call is unused and useless. + * But kept for record of troubles to run on any openjdk. + * upstream patch posted http://mail.openjdk.java.net/pipermail/awt-dev/2014-May/007828.html + */ + private void superRunLoader() { + try { + Class klazz = AppletPanel.class; + Method runLoaderMethod = klazz.getDeclaredMethod("runLoader"); + runLoaderMethod.setAccessible(true); + runLoaderMethod.invoke(getApplet()); + } catch (IllegalAccessException ex1) { + throw new RuntimeException(ex1); + } catch (IllegalArgumentException ex2) { + throw new RuntimeException(ex2); + } catch (NoSuchMethodException ex3) { + throw new RuntimeException(ex3); + } catch (SecurityException ex4) { + throw new RuntimeException(ex4); + } catch (InvocationTargetException ex5) { + throw new RuntimeException(ex5); + } + } + + + protected URL getBaseURL() { + try { + Field field = AppletViewerPanel.class + .getDeclaredField("baseURL"); + field.setAccessible( + true); + return (URL) field.get( + this); + } catch (IllegalAccessException ex1) { + throw new RuntimeException(ex1); + } catch (IllegalArgumentException ex2) { + throw new RuntimeException(ex2); + } catch (NoSuchFieldException ex3) { + throw new RuntimeException(ex3); + } catch (SecurityException ex4) { + throw new RuntimeException(ex4); + } + + } + + + @Override + //remaining stub of unpatched jdk + protected synchronized void createAppletThread() { + throw new RuntimeException("Not yet implemented"); + //no need to call super, is overriden, and not used in upstream + //AppletViewerPanel or AppletPanel + } + + abstract protected void ourRunLoader(); + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/netx/sun/applet/package-info.java Thu Jun 19 14:29:19 2014 +0200 @@ -0,0 +1,37 @@ +/* package-info.java + Copyright (C) 2014 Red Hat, Inc. + +This file is part of IcedTea. + +IcedTea is free software; you can redistribute it and/or modify it under the +terms of the GNU General Public License as published by the Free Software +Foundation, version 2. + +IcedTea 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 for more details. + +You should have received a copy of the GNU General Public License along with +IcedTea; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is making a +combined work based on this library. Thus, the terms and conditions of the GNU +General Public License cover the whole combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent modules, and +to copy and distribute the resulting executable under terms of your choice, +provided that you also meet, for each linked independent module, the terms and +conditions of the license of that module. An independent module is a module +which is not derived from or based on this library. If you modify this library, +you may extend this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this exception +statement from your version.*/ +/** + * This package serve as access to package private classes in JDK. + * <h2>Do not use it for anything else</h2> + */ +package sun.applet;
--- a/plugin/icedteanp/java/sun/applet/PluginAppletPanelFactory.java Thu Jun 19 13:05:26 2014 +0200 +++ b/plugin/icedteanp/java/sun/applet/PluginAppletPanelFactory.java Thu Jun 19 14:29:19 2014 +0200 @@ -87,7 +87,7 @@ final NetxPanel panel = AccessController.doPrivileged(new PrivilegedAction<NetxPanel>() { public NetxPanel run() { NetxPanel panel = new NetxPanel(doc, params); - NetxPanel.debug("Using NetX panel"); + OutputController.getLogger().log("Using NetX panel"); PluginDebug.debug(params.toString()); return panel; }
--- a/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java Thu Jun 19 13:05:26 2014 +0200 +++ b/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java Thu Jun 19 14:29:19 2014 +0200 @@ -642,7 +642,7 @@ pav.dispose(); // If panel is already disposed, return - if (pav.panel.applet == null) { + if (pav.panel.getApplet() == null) { PluginDebug.debug(identifier, " panel inactive. Returning."); return; } @@ -718,8 +718,8 @@ panel.setSize(width, height); panel.validate(); - panel.applet.resize(width, height); - panel.applet.validate(); + panel.getApplet().resize(width, height); + panel.getApplet().validate(); } }); } @@ -1421,8 +1421,8 @@ * at the same time. */ try { - ((AppletViewerPanel)panel).joinAppletThread(); - ((AppletViewerPanel)panel).release(); + ((AppletViewerPanelAccess)panel).joinAppletThread(); + ((AppletViewerPanelAccess)panel).release(); } catch (InterruptedException e) { return; // abort the reload } @@ -1430,7 +1430,7 @@ AccessController.doPrivileged(new PrivilegedAction<Void>() { @Override public Void run() { - ((AppletViewerPanel)panel).createAppletThread(); + ((AppletViewerPanelAccess)panel).createAppletThread(); return null; } });