[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-distro-pkg-dev
Subject:    /hg/icedtea-web: Fixed PR2968 - setContextClassLoaderForAllThrea...
From:       jvanek () icedtea ! classpath ! org
Date:       2016-11-18 11:47:38
Message-ID: hg.6869500e766c.1479469658.8643924302249223276 () icedtea ! classpath ! org
[Download RAW message or body]

changeset 6869500e766c in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=6869500e766c
author: Jiri Vanek <jvanek@redhat.com>
date: Fri Nov 18 12:53:20 2016 +0100

	Fixed PR2968 - setContextClassLoaderForAllThreads for applet called earlier


diffstat:

 ChangeLog                                                                  |   23 +
 NEWS                                                                       |    3 +-
 netx/net/sourceforge/jnlp/Launcher.java                                    |   11 +-
 tests/reproducers/signed/LoadResources/resources/LoadResources1.jnlp       |   56 ++
 tests/reproducers/signed/LoadResources/resources/LoadResources2.jnlp       |   56 ++
 tests/reproducers/signed/LoadResources/resources/LoadResourcesApplet1.jnlp |   61 ++
 tests/reproducers/signed/LoadResources/resources/LoadResourcesApplet2.jnlp |   61 ++
 tests/reproducers/signed/LoadResources/srcs/LoadResources.java             |  186 \
++++++++  tests/reproducers/signed/LoadResources/srcs/LoadResourcesPackaged.java     \
|  187 ++++++++  tests/reproducers/signed/LoadResources/srcs/some.file                \
|    1 +  tests/reproducers/signed/LoadResources/testcases/LoadResourcesTest.java    \
|  223 ++++++++++  11 files changed, 865 insertions(+), 3 deletions(-)

diffs (truncated from 934 to 500 lines):

diff -r bcc0cbd69050 -r 6869500e766c ChangeLog
--- a/ChangeLog	Mon Nov 14 20:11:18 2016 +0100
+++ b/ChangeLog	Fri Nov 18 12:53:20 2016 +0100
@@ -1,3 +1,26 @@
+2016-11-18  Jiri Vanek <jvanek@redhat.com>
+
+	* netx/net/sourceforge/jnlp/Launcher.java: (createApplet) call to \
setContextClassLoaderForAllThreads +	moved to earlier stage to allow \
Thread.currentThread().getContextClassLoader(). call in +	early stages of \
constructions. +	* tests/reproducers/signed/LoadResources/resources/LoadResources1.jnlp:
 +	jnlp for javaws  reproducer in default package
+	* tests/reproducers/signed/LoadResources/resources/LoadResources2.jnlp:
+	jnlp for javaws reproducer in some.pkg package
+	* tests/reproducers/signed/LoadResources/resources/LoadResourcesApplet1.jnlp:
+	jnlp for applet  reproducer in default package
+	* tests/reproducers/signed/LoadResources/resources/LoadResourcesApplet2.jnlp:
+	jnlp for applet reproducer in some.pkg package
+	* tests/reproducers/signed/LoadResources/srcs/LoadResources.java:
+	reproducer in default package calling various getClassLoader
+	* tests/reproducers/signed/LoadResources/srcs/LoadResourcesPackaged.java:
+	reproducer in some.pkg package calling various getClassLoader
+	* tests/reproducers/signed/LoadResources/srcs/some.file:
+	testabel resource
+	* tests/reproducers/signed/LoadResources/testcases/LoadResourcesTest.java:
+	testcase of reproducer
+	* NEWS: mentioned PR2968
+
 2016-11-14  Jiri Vanek <jvanek@redhat.com>
 
 	Fixed PR3227. When filename in cache is to long, it is saved under its hash.
diff -r bcc0cbd69050 -r 6869500e766c NEWS
--- a/NEWS	Mon Nov 14 20:11:18 2016 +0100
+++ b/NEWS	Fri Nov 18 12:53:20 2016 +0100
@@ -58,7 +58,8 @@
   - RH1273691 - Escaped equals signs in deployment.properties not un-escaped when \
                used
   - PR2746 - IcedTea-Web Plugin 1.6.1: net.sourceforge.jnlp.LaunchException 
   - PR2714 - IcedTea-Web plugin sends uninitialized memory garbage across a pipe \
                when NPN_GetValueForURL call fails
-  - PR3198 - Error in webmin (edit) 
+  - PR3198 - Error in webmin
+  - PR2968 - IcedTea-Web crashes on Dell EqualLogic SAN
 
 New in release 1.6 (2015-XX-XX):
 * Massively improved offline abilities. Added Xoffline switch to force work without \
                inet connection.
diff -r bcc0cbd69050 -r 6869500e766c netx/net/sourceforge/jnlp/Launcher.java
--- a/netx/net/sourceforge/jnlp/Launcher.java	Mon Nov 14 20:11:18 2016 +0100
+++ b/netx/net/sourceforge/jnlp/Launcher.java	Fri Nov 18 12:53:20 2016 +0100
@@ -742,6 +742,15 @@
                  appletInstance = new AppletInstance(file, group, loader, null, \
cont);  }
 
+             /**
+              * Due to PR2968, moved to earlier phase, so early stages of appelt
+              * can access Thread.currentThread().getContextClassLoader().
+              *
+              * However it is notable, that init and start still do not have access \
to right classloader. +              * See LoadResources test.
+              */
+             setContextClassLoaderForAllThreads(appletInstance.getThreadGroup(), \
appletInstance.getClassLoader()); +
             loader.setApplication(appletInstance);
 
             // Initialize applet now that ServiceManager has access to its
@@ -754,8 +763,6 @@
             appletInstance.setApplet(applet);
             appletInstance.getAppletEnvironment().setApplet(applet);
             
-            setContextClassLoaderForAllThreads(appletInstance.getThreadGroup(), \
                appletInstance.getClassLoader());
-
             return appletInstance;
         } catch (Exception ex) {
             throw launchError(new LaunchException(file, ex, R("LSFatal"), \
                R("LCInit"), R("LInitApplet"), R("LInitAppletInfo")), \
                appletInstance);
diff -r bcc0cbd69050 -r 6869500e766c \
                tests/reproducers/signed/LoadResources/resources/LoadResources1.jnlp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/reproducers/signed/LoadResources/resources/LoadResources1.jnlp	Fri Nov 18 \
12:53:20 2016 +0100 @@ -0,0 +1,56 @@
+<!--
+
+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; either version 2, or (at your option)
+any later version.
+
+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.
+
+-->
+<?xml version="1.0" encoding="utf-8"?>
+<jnlp spec="1.0" href="LoadResources1.jnlp" codebase=".">
+    <information>
+        <title>simpletest1</title>
+        <vendor>IcedTea</vendor>
+        <homepage href="http://icedtea.classpath.org/wiki/IcedTea-Web#Testing_IcedTea-Web"/>
 +        <description>simpletest1</description>
+        <offline/>
+    </information>
+    <resources>
+        <j2se version="1.4+"/>
+        <jar href="LoadResources.jar"/>
+    </resources>
+    <security>
+        <all-permissions/>
+    </security>
+    <application-desc main-class="LoadResources">
+    </application-desc>
+</jnlp>
diff -r bcc0cbd69050 -r 6869500e766c \
                tests/reproducers/signed/LoadResources/resources/LoadResources2.jnlp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/reproducers/signed/LoadResources/resources/LoadResources2.jnlp	Fri Nov 18 \
12:53:20 2016 +0100 @@ -0,0 +1,56 @@
+<!--
+
+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; either version 2, or (at your option)
+any later version.
+
+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.
+
+-->
+<?xml version="1.0" encoding="utf-8"?>
+<jnlp spec="1.0" href="LoadResources2.jnlp" codebase=".">
+    <information>
+        <title>simpletest1</title>
+        <vendor>IcedTea</vendor>
+        <homepage href="http://icedtea.classpath.org/wiki/IcedTea-Web#Testing_IcedTea-Web"/>
 +        <description>simpletest1</description>
+        <offline/>
+    </information>
+    <resources>
+        <j2se version="1.4+"/>
+        <jar href="LoadResources.jar"/>
+    </resources>
+    <security>
+        <all-permissions/>
+    </security>
+    <application-desc main-class="some.pkg.LoadResourcesPackaged">
+    </application-desc>
+</jnlp>
diff -r bcc0cbd69050 -r 6869500e766c \
                tests/reproducers/signed/LoadResources/resources/LoadResourcesApplet1.jnlp
                
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/reproducers/signed/LoadResources/resources/LoadResourcesApplet1.jnlp	Fri \
Nov 18 12:53:20 2016 +0100 @@ -0,0 +1,61 @@
+<!--
+
+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; either version 2, or (at your option)
+any later version.
+
+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.
+
+-->
+<?xml version="1.0" encoding="utf-8"?>
+<jnlp spec="1.0" href="LoadResourcesApplet1.jnlp" codebase=".">
+    <information>
+        <title>simpletest1</title>
+        <vendor>IcedTea</vendor>
+        <homepage href="http://icedtea.classpath.org/wiki/IcedTea-Web#Testing_IcedTea-Web"/>
 +        <description>simpletest1</description>
+        <offline/>
+    </information>
+    <resources>
+        <j2se version="1.4+"/>
+        <jar href="LoadResources.jar"/>
+    </resources>
+    <security>
+        <all-permissions/>
+    </security>
+    <applet-desc
+        documentBase="."
+        name="LoadResources"
+        main-class="LoadResources"
+        width="250"
+        height="200">
+    </applet-desc>
+</jnlp>
diff -r bcc0cbd69050 -r 6869500e766c \
                tests/reproducers/signed/LoadResources/resources/LoadResourcesApplet2.jnlp
                
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/reproducers/signed/LoadResources/resources/LoadResourcesApplet2.jnlp	Fri \
Nov 18 12:53:20 2016 +0100 @@ -0,0 +1,61 @@
+<!--
+
+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; either version 2, or (at your option)
+any later version.
+
+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.
+
+-->
+<?xml version="1.0" encoding="utf-8"?>
+<jnlp spec="1.0" href="LoadResourcesApplet2.jnlp" codebase=".">
+    <information>
+        <title>simpletest1</title>
+        <vendor>IcedTea</vendor>
+        <homepage href="http://icedtea.classpath.org/wiki/IcedTea-Web#Testing_IcedTea-Web"/>
 +        <description>simpletest1</description>
+        <offline/>
+    </information>
+    <resources>
+        <j2se version="1.4+"/>
+        <jar href="LoadResources.jar"/>
+    </resources>
+    <security>
+        <all-permissions/>
+    </security>
+    <applet-desc
+        documentBase="."
+        name="some.pkg.LoadResourcesPackaged"
+        main-class="some.pkg.LoadResourcesPackaged"
+        width="250"
+        height="200">
+    </applet-desc>
+</jnlp>
diff -r bcc0cbd69050 -r 6869500e766c \
                tests/reproducers/signed/LoadResources/srcs/LoadResources.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/reproducers/signed/LoadResources/srcs/LoadResources.java	Fri Nov 18 \
12:53:20 2016 +0100 @@ -0,0 +1,186 @@
+/* 
+Copyright (C) 2012 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.
+ */
+
+import java.applet.Applet;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
+//import javax.swing.JApplet;
+
+/**
+ * Intentionally copypasted so LoadResource and LoadResource packed do not call
+ * each other or climb outside of its pacakage
+ */
+//public class LoadResources extends JApplet{
+public class LoadResources extends Applet {
+
+    public static final String PASS = "Pass";
+    public static final String FAIL = "Fail";
+
+    public static final String CONTEXT = "context";
+    public static final String CLASS = "class";
+    public static final String SYSTEM = "system";
+    public static final String[] STATIC_LOADERS = new String[]{CONTEXT, CLASS, \
SYSTEM}; +
+    public static final String THIS = "this";
+    public static final String[] INSTANCE_LOADERS = new String[]{THIS};
+
+    public static String[] FILES = new String[]{"some.file", "LoadResources.class", \
"some/pkg/LoadResourcesPackaged.class"}; +    private static String phase;
+
+    static {
+        System.out.println("LoadResources started");
+    }
+
+    public static void main(String[] args) {
+        phase = "MAIN";
+        checkAllStatic();
+    }
+
+    public LoadResources() {
+        phase = "CONSTRUCTOR";
+        checkAllStatic();
+        checkAllInstance();
+    }
+
+    @Override
+    public void init() {
+        phase = "INIT";
+        checkAllStatic();
+        checkAllInstance();
+    }
+
+    @Override
+    public void start() {
+        phase = "START";
+        checkAllStatic();
+        checkAllInstance();
+        System.out.println("*** APPLET FINISHED ***");
+    }
+
+    private static void checkAllStatic() {
+        for (String file : FILES) {
+            for (String loader : STATIC_LOADERS) {
+                checkStaticOnly(loader, file);
+            }
+        }
+    }
+
+    private void checkAllInstance() {
+        for (String file : FILES) {
+            for (String loader : INSTANCE_LOADERS) {
+                checkInstance(loader, file);
+            }
+        }
+    }
+
+    private static void checkStaticOnly(String clType, String resource) {
+        title(clType, resource);
+        try {
+            //we need catch exception both in classlaoder check and resource check
+            ClassLoader cl = getStaticClassLoader(clType);
+            String res = read(getResource(cl, resource));
+            pass(res);
+        } catch (Exception ex) {
+            fail(ex);
+            ex.printStackTrace();
+        }
+
+    }
+
+    private static void fail(Exception ex) {
+        System.out.println(FAIL + " - " + ex.getMessage());
+    }
+
+    private static void pass(String res) {
+        System.out.println(PASS + " - " + res);
+    }
+
+    private static void title(String clType, String resource) {
+        System.out.print("[" + phase + "]" + clType + "(" + resource + "): ");
+        System.err.print("[" + phase + "]" + clType + "(" + resource + "): ");
+    }
+
+    private void checkInstance(String clType, String resource) {
+        title(clType, resource);
+        try {
+            //we need catch exception both in classlaoder check and resource check
+            ClassLoader cl = getInstanceClassLoader(clType);
+            String res = read(getResource(cl, resource));
+            pass(res);
+        } catch (Exception ex) {
+            fail(ex);
+            ex.printStackTrace();
+        }
+
+    }
+
+    private static ClassLoader getStaticClassLoader(String type) {
+        switch (type) {
+            case CONTEXT:
+                return Thread.currentThread().getContextClassLoader();
+
+            case CLASS:
+                return LoadResources.class
+                        .getClassLoader();
+            case SYSTEM:
+                return ClassLoader.getSystemClassLoader();
+        }
+        return null;
+
+    }
+
+    private ClassLoader getInstanceClassLoader(String type) {
+        switch (type) {
+            case THIS:
+                return this.getClass().getClassLoader();
+        }
+        return null;
+    }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic