/hg/icedtea-web: 2 new changesets
adomurad at icedtea.classpath.org
adomurad at icedtea.classpath.org
Tue Aug 28 11:43:59 PDT 2012
changeset e7d3c75b2656 in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=e7d3c75b2656
author: Adam Domurad <adomurad at redhat.com>
date: Tue Aug 28 14:32:12 2012 -0400
Reproducer for PR920, linkage error sometimes occurs
changeset 855087771e7e in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=855087771e7e
author: Adam Domurad <adomurad at redhat.com>
date: Tue Aug 28 14:36:06 2012 -0400
Fix for PR920: Classes attempted to load twice when class extends from outside jar
diffstat:
ChangeLog | 31 ++++-
NEWS | 1 +
netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java | 17 +--
tests/reproducers/custom/AppletExtendsFromOutsideJar/README | 2 +
tests/reproducers/custom/AppletExtendsFromOutsideJar/resources/AppletExtendsFromOutsideJar.html | 45 +++++++
tests/reproducers/custom/AppletExtendsFromOutsideJar/srcs/AppletReferenceInSameJar.java | 43 ++++++
tests/reproducers/custom/AppletExtendsFromOutsideJar/srcs/AppletReferenceOutOfJar.java | 47 +++++++
tests/reproducers/custom/AppletExtendsFromOutsideJar/srcs/Makefile | 27 ++++
tests/reproducers/custom/AppletExtendsFromOutsideJar/srcs/Referenced.java | 40 ++++++
tests/reproducers/custom/AppletExtendsFromOutsideJar/testcases/AppletExtendsFromOutsideJarTests.java | 63 ++++++++++
10 files changed, 300 insertions(+), 16 deletions(-)
diffs (386 lines):
diff -r 26a75e6f28c6 -r 855087771e7e ChangeLog
--- a/ChangeLog Tue Aug 28 10:36:49 2012 -0400
+++ b/ChangeLog Tue Aug 28 14:36:06 2012 -0400
@@ -1,4 +1,33 @@
-2012-08-20 Adam Domurad <adomurad at redhat.com>
+2012-08-27 Adam Domurad <adomurad at redhat.com>
+
+ Fixes PR920, duplicate loading of classes in certain cases
+ * NEWS: Added entry: Fixes PR920
+ * netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java: Remove
+ recursive/non-recursive distinction. Add parent JNLPClassLoader to
+ parent chain.
+
+2012-08-27 Adam Domurad <adomurad at redhat.com>
+
+ Reproduces problem behind PR920, class is in a jar is loaded twice when
+ used by both a class within the jar, and also used by a class outside
+ the jar extending that class.
+ * tests/reproducers/custom/AppletExtendsFromOutsideJar/README:
+ Describes test
+ * tests/reproducers/custom/AppletExtendsFromOutsideJar/resources/AppletExtendsFromOutsideJar.html:
+ Runs applet with main class outside jar
+ * A tests/reproducers/custom/AppletExtendsFromOutsideJar/srcs/AppletReferenceInSameJar.java:
+ References class Referenced inside same jar
+ * tests/reproducers/custom/AppletExtendsFromOutsideJar/srcs/AppletReferenceOutOfJar.java:
+ References class Referenced outside the jar
+ * tests/reproducers/custom/AppletExtendsFromOutsideJar/srcs/Makefile:
+ Packages Reference, AppletReferenceInSameJar into a jar,
+ AppletReferenceOutOfJar outside it
+ * tests/reproducers/custom/AppletExtendsFromOutsideJar/srcs/Referenced.java:
+ Class that is referenced twice, loaded twice in failing behaviour
+ * tests/reproducers/custom/AppletExtendsFromOutsideJar/testcases/AppletExtendsFromOutsideJarTests.java:
+ Drives AppletExtendsFromOutsideJar.html
+
+2012-08-27 Adam Domurad <adomurad at redhat.com>
Tests whether a main class can be found in a jar specified in
META-INF/INDEX.LIST. This test is done with both signed and unsigned
diff -r 26a75e6f28c6 -r 855087771e7e NEWS
--- a/NEWS Tue Aug 28 10:36:49 2012 -0400
+++ b/NEWS Tue Aug 28 14:36:06 2012 -0400
@@ -32,6 +32,7 @@
- PR855: AppletStub getDocumentBase() doesn't return full URL
- PR1011: Folders treated as jar files in archive tag
- PR588: Cookies not written from cookie jar to browser cookies
+ - PR920: Classes attempted to load twice when class extends from outside jar
* Common
- PR918: java applet windows uses a low resulution black/white icon
- RH838417: Disambiguate signed applet security prompt from certificate warning
diff -r 26a75e6f28c6 -r 855087771e7e netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
--- a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java Tue Aug 28 10:36:49 2012 -0400
+++ b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java Tue Aug 28 14:36:06 2012 -0400
@@ -1727,7 +1727,7 @@
// Try codebase loader
if (codeBaseLoader != null)
- return codeBaseLoader.findClass(name, true);
+ return codeBaseLoader.findClass(name);
// All else failed. Throw CNFE
throw new ClassNotFoundException(name);
@@ -2201,7 +2201,7 @@
ConcurrentHashMap<String, URL[]> notFoundResources = new ConcurrentHashMap<String, URL[]>();
public CodeBaseClassLoader(URL[] urls, JNLPClassLoader cl) {
- super(urls);
+ super(urls, cl);
parentJNLPClassLoader = cl;
}
@@ -2212,19 +2212,6 @@
@Override
public Class<?> findClass(String name) throws ClassNotFoundException {
- return findClass(name, false);
- }
-
- public Class<?> findClass(String name, boolean recursivelyInvoked) throws ClassNotFoundException {
-
- if (!recursivelyInvoked) {
- try {
- return parentJNLPClassLoader.findClass(name);
- } catch (ClassNotFoundException cnfe) {
- // continue
- }
- }
-
// If we have searched this path before, don't try again
if (Arrays.equals(super.getURLs(), notFoundResources.get(name)))
throw new ClassNotFoundException(name);
diff -r 26a75e6f28c6 -r 855087771e7e tests/reproducers/custom/AppletExtendsFromOutsideJar/README
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/reproducers/custom/AppletExtendsFromOutsideJar/README Tue Aug 28 14:36:06 2012 -0400
@@ -0,0 +1,2 @@
+This reproducer encapsulates PR920.
+A LinkageError occurs, complaining of duplicate class definition, when an extended class outside of a jar references a common class with its parent class. The common class attempts to load twice.
diff -r 26a75e6f28c6 -r 855087771e7e tests/reproducers/custom/AppletExtendsFromOutsideJar/resources/AppletExtendsFromOutsideJar.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/reproducers/custom/AppletExtendsFromOutsideJar/resources/AppletExtendsFromOutsideJar.html Tue Aug 28 14:36:06 2012 -0400
@@ -0,0 +1,45 @@
+<!--
+
+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.
+
+ -->
+<!-- Runs a jar located in a .class file from the same folder, that uses a class in a .jar file -->
+<html><head></head><body bgcolor="red">
+<p>
+ <applet code="AppletReferenceOutOfJar.class" archive="AppletExtendsFromOutsideJar.jar" codebase="." width="100" height="100">
+ </applet>
+</p>
+</body>
+</html>
diff -r 26a75e6f28c6 -r 855087771e7e tests/reproducers/custom/AppletExtendsFromOutsideJar/srcs/AppletReferenceInSameJar.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/reproducers/custom/AppletExtendsFromOutsideJar/srcs/AppletReferenceInSameJar.java Tue Aug 28 14:36:06 2012 -0400
@@ -0,0 +1,43 @@
+/*
+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 javax.swing.JApplet;
+
+public class AppletReferenceInSameJar extends JApplet {
+
+ Referenced sameJarReference = new Referenced();
+}
diff -r 26a75e6f28c6 -r 855087771e7e tests/reproducers/custom/AppletExtendsFromOutsideJar/srcs/AppletReferenceOutOfJar.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/reproducers/custom/AppletExtendsFromOutsideJar/srcs/AppletReferenceOutOfJar.java Tue Aug 28 14:36:06 2012 -0400
@@ -0,0 +1,47 @@
+/*
+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 javax.swing.JApplet;
+
+public class AppletReferenceOutOfJar extends AppletReferenceInSameJar {
+
+ Referenced outOfJarReference = new Referenced();
+
+ public void init() {
+ System.out.println("My simple applet is running.");
+ }
+}
diff -r 26a75e6f28c6 -r 855087771e7e tests/reproducers/custom/AppletExtendsFromOutsideJar/srcs/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/reproducers/custom/AppletExtendsFromOutsideJar/srcs/Makefile Tue Aug 28 14:36:06 2012 -0400
@@ -0,0 +1,27 @@
+TESTNAME=AppletExtendsFromOutsideJar
+
+SRC_FILES=AppletReferenceInSameJar.java AppletReferenceOutOfJar.java Referenced.java
+JAR_FILES=AppletReferenceInSameJar.class Referenced.class
+OUTER_FILE=AppletReferenceOutOfJar.class
+
+JAVAC_CLASSPATH=$(JNLP_TESTS_ENGINE_DIR):$(NETX_DIR)/lib/classes.jar
+JAVAC=$(BOOT_DIR)/bin/javac
+JAR=$(BOOT_DIR)/bin/jar
+
+TMPDIR:=$(shell mktemp -d)
+
+prepare-reproducer:
+ echo PREPARING REPRODUCER $(TESTNAME) in $(TMPDIR)
+
+ $(JAVAC) -d $(TMPDIR) -classpath $(JAVAC_CLASSPATH) $(SRC_FILES)
+
+ cd $(TMPDIR); \
+ $(JAR) cvf $(TESTNAME).jar $(JAR_FILES); \
+ mv $(OUTER_FILE) $(JNLP_TESTS_SERVER_DEPLOYDIR); \
+ mv $(TESTNAME).jar $(JNLP_TESTS_SERVER_DEPLOYDIR);
+
+ echo PREPARED REPRODUCER $(TESTNAME), removing $(TMPDIR)
+ rm -rf $(TMPDIR)
+
+clean-reproducer:
+ echo NOTHING TO CLEAN FOR $(TESTNAME)
\ No newline at end of file
diff -r 26a75e6f28c6 -r 855087771e7e tests/reproducers/custom/AppletExtendsFromOutsideJar/srcs/Referenced.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/reproducers/custom/AppletExtendsFromOutsideJar/srcs/Referenced.java Tue Aug 28 14:36:06 2012 -0400
@@ -0,0 +1,40 @@
+/*
+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.
+ */
+
+public class Referenced {
+
+}
diff -r 26a75e6f28c6 -r 855087771e7e tests/reproducers/custom/AppletExtendsFromOutsideJar/testcases/AppletExtendsFromOutsideJarTests.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/reproducers/custom/AppletExtendsFromOutsideJar/testcases/AppletExtendsFromOutsideJarTests.java Tue Aug 28 14:36:06 2012 -0400
@@ -0,0 +1,63 @@
+/* AppletExtendsFromOutsideJarTests.java
+Copyright (C) 2011 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 net.sourceforge.jnlp.ProcessResult;
+import net.sourceforge.jnlp.annotations.Bug;
+import net.sourceforge.jnlp.annotations.NeedsDisplay;
+import net.sourceforge.jnlp.annotations.TestInBrowsers;
+import net.sourceforge.jnlp.browsertesting.BrowserTest;
+import net.sourceforge.jnlp.browsertesting.Browsers;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class AppletExtendsFromOutsideJarTests extends BrowserTest {
+
+ private static final String LINKAGE_ERROR_OCCURRENCE = "java.lang.LinkageError: ";
+ private static final String APPLET_RUNNING = "My simple applet is running.";
+
+ @NeedsDisplay
+ @Test
+ @TestInBrowsers(testIn = { Browsers.one })
+ @Bug(id = "PR920")
+ public void testClassInAppletFolder() throws Exception {
+ ProcessResult pr = server.executeBrowser("/AppletExtendsFromOutsideJar.html");
+
+ Assert.assertFalse("Linkage error should not occur but did!", pr.stderr.contains(LINKAGE_ERROR_OCCURRENCE));
+ Assert.assertTrue("Expected '" + APPLET_RUNNING + "', stdout was: " + pr.stdout, pr.stdout.contains(APPLET_RUNNING));
+ }
+}
More information about the distro-pkg-dev
mailing list