diff --git a/tests/reproducers/custom/AppletExtendsFromOutsideJar/README b/tests/reproducers/custom/AppletExtendsFromOutsideJar/README new file mode 100644 --- /dev/null +++ b/tests/reproducers/custom/AppletExtendsFromOutsideJar/README @@ -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 --git a/tests/reproducers/custom/AppletExtendsFromOutsideJar/resources/AppletExtendsFromOutsideJar.html b/tests/reproducers/custom/AppletExtendsFromOutsideJar/resources/AppletExtendsFromOutsideJar.html new file mode 100644 --- /dev/null +++ b/tests/reproducers/custom/AppletExtendsFromOutsideJar/resources/AppletExtendsFromOutsideJar.html @@ -0,0 +1,45 @@ + + + +

+ + +

+ + diff --git a/tests/reproducers/custom/AppletExtendsFromOutsideJar/srcs/AppletReferenceInSameJar.java b/tests/reproducers/custom/AppletExtendsFromOutsideJar/srcs/AppletReferenceInSameJar.java new file mode 100644 --- /dev/null +++ b/tests/reproducers/custom/AppletExtendsFromOutsideJar/srcs/AppletReferenceInSameJar.java @@ -0,0 +1,6 @@ +import javax.swing.JApplet; + +public class AppletReferenceInSameJar extends JApplet { + + Referenced sameJarReference = new Referenced(); +} diff --git a/tests/reproducers/custom/AppletExtendsFromOutsideJar/srcs/AppletReferenceOutOfJar.java b/tests/reproducers/custom/AppletExtendsFromOutsideJar/srcs/AppletReferenceOutOfJar.java new file mode 100644 --- /dev/null +++ b/tests/reproducers/custom/AppletExtendsFromOutsideJar/srcs/AppletReferenceOutOfJar.java @@ -0,0 +1,13 @@ +import javax.swing.JApplet; + +public class AppletReferenceOutOfJar extends AppletReferenceInSameJar { + + Referenced outOfJarReference = new Referenced(); + + public void init() { + System.out.println("My simple applet is running."); + } + + public AppletReferenceOutOfJar() { + } +} diff --git a/tests/reproducers/custom/AppletExtendsFromOutsideJar/srcs/Makefile b/tests/reproducers/custom/AppletExtendsFromOutsideJar/srcs/Makefile new file mode 100644 --- /dev/null +++ b/tests/reproducers/custom/AppletExtendsFromOutsideJar/srcs/Makefile @@ -0,0 +1,27 @@ +TESTNAME=AppletExtendsFromOutsideJar + +DEPLOY_DIR=$(JNLP_TESTS_SERVER_DEPLOYDIR) + +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 + +prepare-reproducer: + echo PREPARING REPRODUCER $(TESTNAME) + $(EXPORTED_JAVAC) -classpath $(JAVAC_CLASSPATH) $(SRC_FILES) + $(JAR) cvf $(TESTNAME).jar $(JAR_FILES) + cp $(OUTER_FILE) $(DEPLOY_DIR)/$(OUTER_FILE) + cp $(TESTNAME).jar $(DEPLOY_DIR)/$(TESTNAME).jar + echo PREPARED REPRODUCER $(TESTNAME) + +clean-reproducer: + echo CLEANING REPRODUCER $(TESTNAME) + rm -f $(OUTER_FILE) + rm -f $(JAR_FILES) + rm -f $(TESTNAME).jar + echo CLEANED REPRODUCER $(TESTNAME) + diff --git a/tests/reproducers/custom/AppletExtendsFromOutsideJar/srcs/Referenced.java b/tests/reproducers/custom/AppletExtendsFromOutsideJar/srcs/Referenced.java new file mode 100644 --- /dev/null +++ b/tests/reproducers/custom/AppletExtendsFromOutsideJar/srcs/Referenced.java @@ -0,0 +1,3 @@ +public class Referenced { + +} diff --git a/tests/reproducers/custom/AppletExtendsFromOutsideJar/testcases/AppletExtendsFromOutsideJarTests.java b/tests/reproducers/custom/AppletExtendsFromOutsideJar/testcases/AppletExtendsFromOutsideJarTests.java new file mode 100644 --- /dev/null +++ b/tests/reproducers/custom/AppletExtendsFromOutsideJar/testcases/AppletExtendsFromOutsideJarTests.java @@ -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)); + } +}