--- old/test/java/io/Serializable/subclass/Allow.policy 2017-05-25 21:20:11.179528582 -0700 +++ new/test/java/io/Serializable/subclass/Allow.policy 2017-05-25 21:20:10.768528558 -0700 @@ -2,7 +2,6 @@ // "standard" properies that can be read by anyone permission java.io.FilePermission "-","read,write,execute"; permission java.io.SerializablePermission "enableSubstitution"; - permission java.io.SerializablePermission "enableSubclassImplementation"; // Needed to get access to private writeObjectMethod and // to be able to call it. --- /dev/null 2017-05-26 01:02:49.226221427 -0700 +++ new/test/java/io/Serializable/evolution/RenamePackage/RenamePackageTest.java 2017-05-25 21:20:11.667528610 -0700 @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * 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. + * + * 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). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4087295 4785472 + * @library /test/lib + * @build jdk.test.lib.compiler.CompilerUtils + * @build jdk.test.lib.process.ProcessTools + * @build RenamePackageTest + * @run main RenamePackageTest + * @summary Enable resolveClass() to accommodate package renaming. + * This fix enables one to implement a resolveClass method that maps a + * Serialiazable class within a serialization stream to the same class + * in a different package within the JVM runtime. See run shell script + * for instructions on how to run this test. + */ + +import java.io.File; +import java.nio.file.Path; +import java.nio.file.Paths; + +import jdk.test.lib.compiler.CompilerUtils; +import jdk.test.lib.process.ProcessTools; + +public class RenamePackageTest { + public static void main(String args[]) throws Exception { + sutup(); + + runTestSerialDriver(); + runInstallSerialDriver(); + + runInstallSerialDriver(); + runTestSerialDriver(); + } + + private static final Path SHARE = Paths.get(System.getProperty("test.classes"), "share"); + private static final Path OCLASSES = Paths.get(System.getProperty("test.classes"), "oclasses"); + private static final Path NCLASSES = Paths.get(System.getProperty("test.classes"), "nclasses"); + + private static void sutup() throws Exception { + + boolean b = CompilerUtils.compile(Paths.get(System.getProperty("test.src"), "extension"), + SHARE); + assertTrue(b); + b = CompilerUtils.compile(Paths.get(System.getProperty("test.src"), "test"), + OCLASSES, + "-classpath", + SHARE.toString()); + assertTrue(b); + b = CompilerUtils.compile(Paths.get(System.getProperty("test.src"), "install"), + NCLASSES, + "-classpath", + SHARE.toString()); + assertTrue(b); + } + + private static void runTestSerialDriver() throws Exception { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, + "-classpath", + SHARE.toString() + + File.pathSeparator + + OCLASSES.toString(), + "test.SerialDriver", "-s"); + Process p = ProcessTools.startProcess("test SerialDriver", pb); + p.waitFor(); + assertTrue(p.exitValue() == 0); + } + + private static void runInstallSerialDriver() throws Exception { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, + "-classpath", + SHARE.toString() + + File.pathSeparator + + NCLASSES.toString(), + "install.SerialDriver", "-d"); + Process p = ProcessTools.startProcess("install SerialDriver", pb); + p.waitFor(); + assertTrue(p.exitValue() == 0); + } + + private static void assertTrue(boolean b) { + if (!b) { + throw new RuntimeException("expected true, get false"); + } + } +} --- old/test/java/io/Serializable/maskSyntheticModifier/Test.java 2017-05-25 21:20:12.666528667 -0700 +++ /dev/null 2017-05-26 01:02:49.226221427 -0700 @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. - * 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. - * - * 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). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @bug 4897937 - * @summary Verify that the presence of the JVM_ACC_SYNTHETIC bit in the - * modifiers of fields and methods does not affect default - * serialVersionUID calculation. - */ - -import java.io.ObjectStreamClass; - -public class Test { - public static void main(String[] args) { - long suid = ObjectStreamClass.lookup(Foo.class).getSerialVersionUID(); - if (suid != 8027844768744011556L) { - throw new Error("incorrect serialVersionUID: " + suid); - } - } -} --- /dev/null 2017-05-26 01:02:49.226221427 -0700 +++ new/test/java/io/Serializable/maskSyntheticModifier/MaskSyntheticModifierTest.java 2017-05-25 21:20:12.358528649 -0700 @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. + * 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. + * + * 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). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4897937 + * @run main MaskSyntheticModifierTest + * @summary Verify that the presence of the JVM_ACC_SYNTHETIC bit in the + * modifiers of fields and methods does not affect default + * serialVersionUID calculation. + */ + +import java.io.ObjectStreamClass; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; + +public class MaskSyntheticModifierTest { + public static void main(String[] args) throws Exception { + setup(); + + long suid = ObjectStreamClass.lookup(Foo.class).getSerialVersionUID(); + if (suid != 8027844768744011556L) { + throw new Error("incorrect serialVersionUID: " + suid); + } + } + + private static void setup() throws Exception { + Files.copy(Paths.get(System.getProperty("test.src"), "Foo.class"), + Paths.get("Foo.class"), StandardCopyOption.REPLACE_EXISTING); + } +} --- old/test/java/io/Serializable/packageAccess/Test.java 2017-05-25 21:20:13.297528703 -0700 +++ /dev/null 2017-05-26 01:02:49.226221427 -0700 @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. - * 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. - * - * 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). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @bug 4765255 - * @summary Verify proper functioning of package equality checks used to - * determine accessibility of superclass constructor and inherited - * writeReplace/readResolve methods. - */ - -import java.io.*; -import java.net.*; - -public class Test { - - static Class bcl; - static Class dcl; - - public static void main(String[] args) throws Exception { - ClassLoader ldr = - new URLClassLoader(new URL[]{ new URL("file:foo.jar") }, - Test.class.getClassLoader()); - bcl = Class.forName("B", true, ldr); - dcl = Class.forName("D", true, ldr); - - Object b = bcl.newInstance(); - try { - swizzle(b); - throw new Error("expected InvalidClassException for class B"); - } catch (InvalidClassException e) { - System.out.println("caught " + e); - e.printStackTrace(); - } - if (A.packagePrivateConstructorInvoked) { - throw new Error("package private constructor of A invoked"); - } - - Object d = dcl.newInstance(); - swizzle(d); - } - - static void swizzle(Object obj) throws Exception { - ByteArrayOutputStream bout = new ByteArrayOutputStream(); - ObjectOutputStream oout = new ObjectOutputStream(bout); - oout.writeObject(obj); - oout.close(); - ByteArrayInputStream bin = - new ByteArrayInputStream(bout.toByteArray()); - new TestObjectInputStream(bin).readObject(); - } -} - -class TestObjectInputStream extends ObjectInputStream { - TestObjectInputStream(InputStream in) throws IOException { - super(in); - } - - protected Class resolveClass(ObjectStreamClass desc) - throws IOException, ClassNotFoundException - { - String n = desc.getName(); - if (n.equals("B")) { - return Test.bcl; - } else if (n.equals("D")) { - return Test.dcl; - } else { - return super.resolveClass(desc); - } - } -} --- /dev/null 2017-05-26 01:02:49.226221427 -0700 +++ new/test/java/io/Serializable/packageAccess/PackageAccessTest.java 2017-05-25 21:20:13.022528687 -0700 @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved. + * 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. + * + * 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). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4765255 + * @library /lib/testlibrary + * @build JarUtils A B C D PackageAccessTest + * @run main PackageAccessTest + * @summary Verify proper functioning of package equality checks used to + * determine accessibility of superclass constructor and inherited + * writeReplace/readResolve methods. + */ + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.InputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.ObjectStreamClass; +import java.io.InvalidClassException; +import java.net.URL; +import java.net.URLClassLoader; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +public class PackageAccessTest { + + static Class bcl; + static Class dcl; + + public static void main(String[] args) throws Exception { + setup(); + + URLClassLoader ldr = + new URLClassLoader(new URL[]{ new URL("file:foo.jar") }, + PackageAccessTest.class.getClassLoader()); + bcl = Class.forName("B", true, ldr); + dcl = Class.forName("D", true, ldr); + + Object b = bcl.newInstance(); + try { + swizzle(b); + throw new Error("expected InvalidClassException for class B"); + } catch (InvalidClassException e) { + System.out.println("caught " + e); + e.printStackTrace(); + } + if (A.packagePrivateConstructorInvoked) { + throw new Error("package private constructor of A invoked"); + } + + Object d = dcl.newInstance(); + swizzle(d); + ldr.close(); + } + + static void swizzle(Object obj) throws Exception { + ByteArrayOutputStream bout = new ByteArrayOutputStream(); + ObjectOutputStream oout = new ObjectOutputStream(bout); + oout.writeObject(obj); + oout.close(); + ByteArrayInputStream bin = + new ByteArrayInputStream(bout.toByteArray()); + new TestObjectInputStream(bin).readObject(); + } + + static void setup() throws Exception { + Path classes = Paths.get(System.getProperty("test.classes", "")); + JarUtils.createJarFile(Paths.get("foo.jar"), classes, + classes.resolve("B.class"), classes.resolve("D.class")); + Files.delete(classes.resolve("B.class")); + Files.delete(classes.resolve("D.class")); + } +} + +class TestObjectInputStream extends ObjectInputStream { + TestObjectInputStream(InputStream in) throws IOException { + super(in); + } + + protected Class resolveClass(ObjectStreamClass desc) + throws IOException, ClassNotFoundException + { + String n = desc.getName(); + if (n.equals("B")) { + return PackageAccessTest.bcl; + } else if (n.equals("D")) { + return PackageAccessTest.dcl; + } else { + return super.resolveClass(desc); + } + } +} --- old/test/java/io/Serializable/resolveClass/consTest/Test.java 2017-05-25 21:20:13.917528738 -0700 +++ /dev/null 2017-05-26 01:02:49.226221427 -0700 @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. - * 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. - * - * 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). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @bug 4413434 - * @summary Verify that generated java.lang.reflect implementation classes do - * not interfere with serialization's class resolution mechanism. - */ - -import java.io.*; -import java.lang.reflect.*; - -public class Test implements Serializable { - public static void main(String[] args) throws Exception { - Constructor cons = Boot.class.getConstructor( - new Class[] { ObjectInputStream.class }); - ByteArrayOutputStream bout = new ByteArrayOutputStream(); - ObjectOutputStream oout = new ObjectOutputStream(bout); - oout.writeObject(new Test()); - oout.close(); - - for (int i = 0; i < 100; i++) { - ObjectInputStream oin = new ObjectInputStream( - new ByteArrayInputStream(bout.toByteArray())); - cons.newInstance(new Object[]{ oin }); - } - } -} --- /dev/null 2017-05-26 01:02:49.226221427 -0700 +++ new/test/java/io/Serializable/resolveClass/consTest/ConsTest.java 2017-05-25 21:20:13.630528722 -0700 @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved. + * 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. + * + * 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). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4413434 + * @library /lib/testlibrary + * @build JarUtils SetupJar Boot + * @run driver SetupJar + * @run main/othervm -Xbootclasspath/a:boot.jar ConsTest + * @summary Verify that generated java.lang.reflect implementation classes do + * not interfere with serialization's class resolution mechanism. + */ + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.lang.reflect.Constructor; + +public class ConsTest implements Serializable { + public static void main(String[] args) throws Exception { + Constructor cons = Boot.class.getConstructor( + new Class[] { ObjectInputStream.class }); + ByteArrayOutputStream bout = new ByteArrayOutputStream(); + ObjectOutputStream oout = new ObjectOutputStream(bout); + oout.writeObject(new ConsTest()); + oout.close(); + + for (int i = 0; i < 100; i++) { + ObjectInputStream oin = new ObjectInputStream( + new ByteArrayInputStream(bout.toByteArray())); + cons.newInstance(new Object[]{ oin }); + } + } +} --- /dev/null 2017-05-26 01:02:49.226221427 -0700 +++ new/test/java/io/Serializable/resolveClass/consTest/SetupJar.java 2017-05-25 21:20:14.233528756 -0700 @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * 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. + * + * 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). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.nio.file.Path; +import java.nio.file.Paths; + +public class SetupJar { + + public static void main(String args[]) throws Exception { + Path classes = Paths.get(System.getProperty("test.classes", "")); + JarUtils.createJarFile(Paths.get("boot.jar"), classes, + classes.resolve("Boot.class")); + } +} --- old/test/java/io/Serializable/resolveClass/deserializeButton/Test.java 2017-05-25 21:20:15.118528806 -0700 +++ /dev/null 2017-05-26 01:02:49.226221427 -0700 @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. - * 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. - * - * 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). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @bug 4413434 - * @summary Verify that class loaded outside of application class loader is - * correctly resolved during deserialization when read in by custom - * readObject() method of a bootstrap class (in this case, - * java.util.Vector). - */ - -import java.io.*; -import java.net.*; - -public class Test { - public static void main(String[] args) throws Exception { - ClassLoader ldr = - new URLClassLoader(new URL[]{ new URL("file:cb.jar") }); - Runnable r = (Runnable) Class.forName("Foo", true, ldr).newInstance(); - r.run(); - } -} --- /dev/null 2017-05-26 01:02:49.226221427 -0700 +++ new/test/java/io/Serializable/resolveClass/deserializeButton/DeserializeButtonTest.java 2017-05-25 21:20:14.879528793 -0700 @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved. + * 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. + * + * 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). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4413434 + * @library /lib/testlibrary + * @build JarUtils Foo + * @run main DeserializeButtonTest + * @summary Verify that class loaded outside of application class loader is + * correctly resolved during deserialization when read in by custom + * readObject() method of a bootstrap class (in this case, + * java.util.Vector). + */ + +import java.net.URLClassLoader; +import java.net.URL; +import java.nio.file.Path; +import java.nio.file.Paths; + +public class DeserializeButtonTest { + public static void main(String[] args) throws Exception { + setup(); + + URLClassLoader ldr = + new URLClassLoader(new URL[]{ new URL("file:cb.jar") }); + Runnable r = (Runnable) Class.forName("Foo", true, ldr).newInstance(); + r.run(); + ldr.close(); + } + + private static void setup() throws Exception { + Path classes = Paths.get(System.getProperty("test.classes", "")); + JarUtils.createJarFile(Paths.get("cb.jar"), + classes, + classes.resolve("Foo.class"), + classes.resolve("Foo$TestElement.class")); + } +} --- old/test/java/io/Serializable/serialver/classpath/Test.java 2017-05-25 21:20:15.757528843 -0700 +++ /dev/null 2017-05-26 01:02:49.226221427 -0700 @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved. - * 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. - * - * 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). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * - * @bug 4035147 - * @sumary Simple java class for test purposes - */ - -package serialver; - -public class Test implements java.io.Serializable{ - int a; - int b; -} --- /dev/null 2017-05-26 01:02:49.226221427 -0700 +++ new/test/java/io/Serializable/serialver/classpath/ClasspathTest.java 2017-05-25 21:20:15.501528828 -0700 @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. + * 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. + * + * 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). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4035147 4785472 + * @library /test/lib + * @build jdk.test.lib.JDKToolLauncher + * @build jdk.test.lib.process.ProcessTools + * @build ClasspathTest + * @run main serialver.ClasspathTest + * @summary Test the use of the -classpath switch in the serialver application. + */ + +package serialver; + +import java.io.File; + +import jdk.test.lib.JDKToolLauncher; +import jdk.test.lib.process.ProcessTools; + +public class ClasspathTest implements java.io.Serializable{ + int a; + int b; + + public static void main(String args[]) throws Exception { + JDKToolLauncher serialver = + JDKToolLauncher.create("serialver") + .addToolArg("-classpath") + .addToolArg(System.getProperty("test.class.path")) + .addToolArg("serialver.ClasspathTest"); + Process p = ProcessTools.startProcess("serialver", + new ProcessBuilder(serialver.getCommand())); + p.waitFor(); + if (p.exitValue() != 0) { + throw new RuntimeException("error occurs in serialver."); + } + } +} --- old/test/java/io/Serializable/serialver/nested/Test.java 2017-05-25 21:20:16.291528873 -0700 +++ /dev/null 2017-05-26 01:02:49.226221427 -0700 @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved. - * 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. - * - * 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). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * - * @bug 4312217 - * @summary To test the use of nested class specification using the '.' - * notation instead of the '$' notation. - */ -package serialver; - -import java.io.*; - -public class Test implements Serializable { - public static class Test1 implements Serializable { - public static class Test2 implements Serializable{ - private static final long serialVersionUID = 100L; - } - } -} --- /dev/null 2017-05-26 01:02:49.226221427 -0700 +++ new/test/java/io/Serializable/serialver/nested/NestedTest.java 2017-05-25 21:20:16.076528861 -0700 @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. + * 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. + * + * 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). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4312217 4785473 + * @library /test/lib + * @build jdk.test.lib.JDKToolLauncher + * @build jdk.test.lib.process.ProcessTools + * @build NestedTest + * @run main serialver.NestedTest + * @summary To test the use of nested class specification using the '.' + * notation instead of the '$' notation. + */ + +package serialver; + +import java.io.Serializable; + +import jdk.test.lib.JDKToolLauncher; +import jdk.test.lib.process.ProcessTools; + +public class NestedTest implements Serializable { + public static class Test1 implements Serializable { + public static class Test2 implements Serializable{ + private static final long serialVersionUID = 100L; + } + } + + public static void main(String args[]) throws Exception { + JDKToolLauncher serialver = + JDKToolLauncher.create("serialver") + .addToolArg("-classpath") + .addToolArg(System.getProperty("test.class.path")) + .addToolArg("serialver.NestedTest.Test1.Test2"); + Process p = ProcessTools.startProcess("serialver", + new ProcessBuilder(serialver.getCommand())); + p.waitFor(); + if (p.exitValue() != 0) { + throw new RuntimeException("error occurs in serialver."); + } + } +} --- old/test/java/io/Serializable/subclass/Test.java 2017-05-25 21:20:16.861528906 -0700 +++ /dev/null 2017-05-26 01:02:49.226221427 -0700 @@ -1,152 +0,0 @@ -/* - * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved. - * 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. - * - * 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). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 4100915 - * @summary Verify that [write/read]ObjectOverride methods get called. - * Test verifies that ALL methods to write an object can - * be overridden. Howver, the testing for reading an object - * is incomplete. Only test that readObjectOverride is called. - * An entire protocol would need to be implemented and written - * out before being able to test the input side of the API. - * - * Also, would be appropriate that this program verify - * that if SerializablePermission "enableSubclassImplamentation" - * is not in the security policy and security is enabled, that - * a security excepiton is thrown when constructing the - * ObjectOutputStream subclass. - * - * - * @compile AbstractObjectInputStream.java AbstractObjectOutputStream.java XObjectInputStream.java XObjectOutputStream.java Test.java - * @run main Test - */ - -import java.io.*; - -/** - * Test if customized readObject and writeObject are called. - */ -class B implements Serializable { - public int publicIntField; - public static int numWriteObjectCalled = 0; - B(int v) { - publicIntField = v; - } - private void writeObject(ObjectOutputStream os) throws IOException { - numWriteObjectCalled++; - os.defaultWriteObject(); - } - - private void readObject(ObjectInputStream is) - throws IOException, ClassNotFoundException - { - is.defaultReadObject(); - } - -}; - -/** - * Test PutFields interface. - */ - -class C implements Serializable { - public int xx1; - public int xx2; - static final ObjectStreamField[] serialPersistentFields = { - new ObjectStreamField("x1", Integer.TYPE), - new ObjectStreamField("x2", Integer.TYPE), - new ObjectStreamField("x3", Integer.TYPE), - new ObjectStreamField("x4", Integer.TYPE) - }; - C() { - xx1 = 300; - xx2 = 400; - } - - private void writeObject(ObjectOutputStream os) throws IOException { - ObjectOutputStream.PutField putFields = os.putFields(); - putFields.put("x1", xx1); - putFields.put("x2", xx2); - putFields.put("x3", xx1 * 2); - putFields.put("x4", xx2 * 2); - os.writeFields(); - } - -}; - - -class A implements Serializable { - public int publicIntField; - public long publicLongField; - public B publicBField; - public B[] publicBArray = { new B(4), new B(6)}; - public C publicCField; - - public A() { - publicIntField = 3; - publicLongField = 10L; - publicBField = new B(5); - publicCField = new C(); - } -}; - -public class Test { - public static void main(String argv[]) - throws IOException, ClassNotFoundException - { - boolean expectSecurityException = false; - - if (argv.length > 0 && - argv[0].compareTo("-expectSecurityException") == 0) - expectSecurityException = true; - - ByteArrayOutputStream baos = new ByteArrayOutputStream(20); - XObjectOutputStream os = null; - try { - os = new XObjectOutputStream(baos); - if (expectSecurityException) - throw new Error("Assertion failure. " + - "Expected a security exception on previous line."); - } catch (SecurityException e) { - if (expectSecurityException) - return; - else - throw e; - } - os.writeObject(new A()); - os.close(); - if (B.numWriteObjectCalled != 3) - throw new Error("Expected B.writeObject() to be called 3 times;" + - " observed only " + B.numWriteObjectCalled + " times"); - - XObjectInputStream is = - new XObjectInputStream(new ByteArrayInputStream(baos.toByteArray())); - try { - A a = (A)is.readObject(); - throw new Error("Expected readObjectOverride() to be called and throw IOException(not implemented)"); - } catch (IOException e) { - } - is.close(); - } -}; --- /dev/null 2017-05-26 01:02:49.226221427 -0700 +++ new/test/java/io/Serializable/subclass/SubclassTest.java 2017-05-25 21:20:16.639528893 -0700 @@ -0,0 +1,162 @@ +/* + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. + * 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. + * + * 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). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4100915 + * @summary Verify that [write/read]ObjectOverride methods get called. + * Test verifies that ALL methods to write an object can + * be overridden. However, the testing for reading an object + * is incomplete. Only test that readObjectOverride is called. + * An entire protocol would need to be implemented and written + * out before being able to test the input side of the API. + * + * Also, would be appropriate that this program verify + * that if SerializablePermission "enableSubclassImplementation" + * is not in the security policy and security is enabled, that + * a security excepiton is thrown when constructing the + * ObjectOutputStream subclass. + * + * + * @compile AbstractObjectInputStream.java AbstractObjectOutputStream.java + * @compile XObjectInputStream.java XObjectOutputStream.java + * @compile SubclassTest.java + * @run main SubclassTest + * @run main/othervm/policy=Allow.policy SubclassTest -expectSecurityException + */ + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.ObjectStreamField; +import java.io.Serializable; + +/** + * Test if customized readObject and writeObject are called. + */ +class B implements Serializable { + public int publicIntField; + public static int numWriteObjectCalled = 0; + B(int v) { + publicIntField = v; + } + private void writeObject(ObjectOutputStream os) throws IOException { + numWriteObjectCalled++; + os.defaultWriteObject(); + } + + private void readObject(ObjectInputStream is) + throws IOException, ClassNotFoundException + { + is.defaultReadObject(); + } + +}; + +/** + * Test PutFields interface. + */ + +class C implements Serializable { + public int xx1; + public int xx2; + static final ObjectStreamField[] serialPersistentFields = { + new ObjectStreamField("x1", Integer.TYPE), + new ObjectStreamField("x2", Integer.TYPE), + new ObjectStreamField("x3", Integer.TYPE), + new ObjectStreamField("x4", Integer.TYPE) + }; + C() { + xx1 = 300; + xx2 = 400; + } + + private void writeObject(ObjectOutputStream os) throws IOException { + ObjectOutputStream.PutField putFields = os.putFields(); + putFields.put("x1", xx1); + putFields.put("x2", xx2); + putFields.put("x3", xx1 * 2); + putFields.put("x4", xx2 * 2); + os.writeFields(); + } + +}; + + +class A implements Serializable { + public int publicIntField; + public long publicLongField; + public B publicBField; + public B[] publicBArray = { new B(4), new B(6)}; + public C publicCField; + + public A() { + publicIntField = 3; + publicLongField = 10L; + publicBField = new B(5); + publicCField = new C(); + } +}; + +public class SubclassTest { + public static void main(String argv[]) + throws IOException, ClassNotFoundException + { + boolean expectSecurityException = false; + + if (argv.length > 0 && + argv[0].compareTo("-expectSecurityException") == 0) + expectSecurityException = true; + + ByteArrayOutputStream baos = new ByteArrayOutputStream(20); + XObjectOutputStream os = null; + try { + os = new XObjectOutputStream(baos); + if (expectSecurityException) + throw new Error("Assertion failure. " + + "Expected a security exception on previous line."); + } catch (SecurityException e) { + if (expectSecurityException) { + System.err.println("Caught expected security exception."); + return; + } + throw e; + } + os.writeObject(new A()); + os.close(); + if (B.numWriteObjectCalled != 3) + throw new Error("Expected B.writeObject() to be called 3 times;" + + " observed only " + B.numWriteObjectCalled + " times"); + + XObjectInputStream is = + new XObjectInputStream(new ByteArrayInputStream(baos.toByteArray())); + try { + A a = (A)is.readObject(); + throw new Error("Expected readObjectOverride() to be called and throw IOException(not implemented)"); + } catch (IOException e) { + } + is.close(); + } +}; --- old/test/java/io/Serializable/superclassDataLoss/Test.java 2017-05-25 21:20:17.485528941 -0700 +++ /dev/null 2017-05-26 01:02:49.226221427 -0700 @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved. - * 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. - * - * 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). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @bug 4325590 - * @summary Verify that superclass data is not lost when incoming superclass - * descriptor is matched with local class that is not a superclass of - * the deserialized instance's class. - */ - -import java.io.*; -import java.net.*; - -class MixedSuperclassStream extends ObjectInputStream { - MixedSuperclassStream(InputStream in) throws IOException { super(in); } - - protected Class resolveClass(ObjectStreamClass desc) - throws IOException, ClassNotFoundException - { - // resolve A's classdesc to class != B's superclass - String name = desc.getName(); - if (name.equals("A")) { - return Class.forName(name, true, Test.ldr1); - } else if (name.equals("B")) { - return Class.forName(name, true, Test.ldr2); - } else { - return super.resolveClass(desc); - } - } -} - -public class Test { - - static URLClassLoader ldr1, ldr2; - static { - try { - ldr1 = new URLClassLoader(new URL[] { new URL("file:cb1.jar") }); - ldr2 = new URLClassLoader(new URL[] { new URL("file:cb2.jar") }); - } catch (MalformedURLException ex) { - throw new Error(); - } - } - - public static void main(String[] args) throws Exception { - Runnable a = (Runnable) Class.forName("B", true, ldr1).newInstance(); - a.run(); - - ByteArrayOutputStream bout = new ByteArrayOutputStream(); - ObjectOutputStream oout = new ObjectOutputStream(bout); - oout.writeObject(a); - oout.close(); - - ByteArrayInputStream bin = - new ByteArrayInputStream(bout.toByteArray()); - ObjectInputStream oin = new MixedSuperclassStream(bin); - a = (Runnable) oin.readObject(); - a.run(); - } -} --- /dev/null 2017-05-26 01:02:49.226221427 -0700 +++ new/test/java/io/Serializable/superclassDataLoss/SuperclassDataLossTest.java 2017-05-25 21:20:17.177528924 -0700 @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. + * 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. + * + * 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). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4325590 + * @library /lib/testlibrary + * @build JarUtils A B + * @run main SuperclassDataLossTest + * @summary Verify that superclass data is not lost when incoming superclass + * descriptor is matched with local class that is not a superclass of + * the deserialized instance's class. + */ + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.InputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.ObjectStreamClass; +import java.net.URL; +import java.net.URLClassLoader; +import java.net.MalformedURLException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; + +class MixedSuperclassStream extends ObjectInputStream { + private boolean ldr12A; + + MixedSuperclassStream(InputStream in, boolean ldr1First) throws IOException { + super(in); + this.ldr12A = ldr12A; + } + + protected Class resolveClass(ObjectStreamClass desc) + throws IOException, ClassNotFoundException + { + // resolve A's classdesc to class != B's superclass + String name = desc.getName(); + if (ldr12A) { + if (name.equals("A")) { + return Class.forName(name, true, SuperclassDataLossTest.ldr1); + } else if (name.equals("B")) { + return Class.forName(name, true, SuperclassDataLossTest.ldr2); + } + } else { + if (name.equals("B")) { + return Class.forName(name, true, SuperclassDataLossTest.ldr1); + } else if (name.equals("A")) { + return Class.forName(name, true, SuperclassDataLossTest.ldr2); + } + } + return super.resolveClass(desc); + } +} + +public class SuperclassDataLossTest { + + static URLClassLoader ldr1, ldr2; + static { + try { + ldr1 = new URLClassLoader(new URL[] { new URL("file:cb1.jar") }); + ldr2 = new URLClassLoader(new URL[] { new URL("file:cb2.jar") }); + } catch (MalformedURLException ex) { + throw new Error(); + } + } + + public static void main(String[] args) throws Exception { + setup(); + + Runnable a = (Runnable) Class.forName("B", true, ldr1).newInstance(); + a.run(); + + ByteArrayOutputStream bout = new ByteArrayOutputStream(); + ObjectOutputStream oout = new ObjectOutputStream(bout); + oout.writeObject(a); + oout.close(); + + test(bout, true); + test(bout, false); + + ldr1.close(); + ldr2.close(); + } + + private static void test(ByteArrayOutputStream bout, boolean ldr12A) throws Exception { + ByteArrayInputStream bin = + new ByteArrayInputStream(bout.toByteArray()); + ObjectInputStream oin = new MixedSuperclassStream(bin, ldr12A); + Runnable a = (Runnable) oin.readObject(); + a.run(); + } + + private static void setup() throws Exception { + Path classes = Paths.get(System.getProperty("test.classes", "")); + JarUtils.createJarFile(Paths.get("cb1.jar"), classes, + classes.resolve("A.class"), classes.resolve("B.class")); + Files.copy(Paths.get("cb1.jar"), Paths.get("cb2.jar"), + StandardCopyOption.REPLACE_EXISTING); + } +} --- old/test/java/io/Serializable/unnamedPackageSwitch/Test.java 2017-05-25 21:20:18.220528983 -0700 +++ /dev/null 2017-05-26 01:02:49.226221427 -0700 @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved. - * 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. - * - * 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). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @bug 4348213 - * @summary Verify that deserialization allows an incoming class descriptor - * representing a class in the unnamed package to be resolved to a - * local class with the same name in a named package, and vice-versa. - */ - -import java.io.*; - -class A implements Serializable { - private static final long serialVersionUID = 0L; -} - -class TestObjectInputStream extends ObjectInputStream { - TestObjectInputStream(InputStream in) throws IOException { super(in); } - protected Class resolveClass(ObjectStreamClass desc) - throws IOException, ClassNotFoundException - { - String name = desc.getName(); - if (name.equals("A")) { - return pkg.A.class; - } else if (name.equals("pkg.A")) { - return A.class; - } else { - return super.resolveClass(desc); - } - } -} - -public class Test { - public static void main(String[] args) throws Exception { - ByteArrayOutputStream bout = new ByteArrayOutputStream(); - ObjectOutputStream oout = new ObjectOutputStream(bout); - oout.writeObject(new A()); - oout.writeObject(new pkg.A()); - oout.close(); - - ObjectInputStream oin = new TestObjectInputStream( - new ByteArrayInputStream(bout.toByteArray())); - oin.readObject(); - oin.readObject(); - } -} --- /dev/null 2017-05-26 01:02:49.226221427 -0700 +++ new/test/java/io/Serializable/unnamedPackageSwitch/UnnamedPackageSwitchTest.java 2017-05-25 21:20:17.997528970 -0700 @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. + * 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. + * + * 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). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4348213 + * @build UnnamedPackageSwitchTest pkg.A + * @run main UnnamedPackageSwitchTest + * @summary Verify that deserialization allows an incoming class descriptor + * representing a class in the unnamed package to be resolved to a + * local class with the same name in a named package, and vice-versa. + */ + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.InputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectStreamClass; +import java.io.Serializable; + +class A implements Serializable { + private static final long serialVersionUID = 0L; +} + +class TestObjectInputStream extends ObjectInputStream { + TestObjectInputStream(InputStream in) throws IOException { super(in); } + protected Class resolveClass(ObjectStreamClass desc) + throws IOException, ClassNotFoundException + { + String name = desc.getName(); + if (name.equals("A")) { + return pkg.A.class; + } else if (name.equals("pkg.A")) { + return A.class; + } else { + return super.resolveClass(desc); + } + } +} + +public class UnnamedPackageSwitchTest { + public static void main(String[] args) throws Exception { + ByteArrayOutputStream bout = new ByteArrayOutputStream(); + ObjectOutputStream oout = new ObjectOutputStream(bout); + oout.writeObject(new A()); + oout.writeObject(new pkg.A()); + oout.close(); + + ObjectInputStream oin = new TestObjectInputStream( + new ByteArrayInputStream(bout.toByteArray())); + oin.readObject(); + oin.readObject(); + } +} --- old/test/java/io/Serializable/evolution/AddedExternField/run.sh 2017-05-25 21:20:18.810529017 -0700 +++ /dev/null 2017-05-26 01:02:49.226221427 -0700 @@ -1,33 +0,0 @@ -# -# Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. -# 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. -# -# 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). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# -# @bug 4088176 -# @summary Test reading an evolved class serialization into the original class - -rm *.class tmp.ser -javac WriteAddedField.java -java ${TESTVMOPTS} WriteAddedField -rm *.class -javac ReadAddedField.java -java ${TESTVMOPTS} ReadAddedField --- old/test/java/io/Serializable/evolution/RenamePackage/run.sh 2017-05-25 21:20:19.196529039 -0700 +++ /dev/null 2017-05-26 01:02:49.226221427 -0700 @@ -1,105 +0,0 @@ -# -# Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. -# 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. -# -# 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). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# @test -# @bug 4087295 4785472 -# @summary Enable resolveClass() to accommodate package renaming. -# This fix enables one to implement a resolveClass method that maps a -# Serialiazable class within a serialization stream to the same class -# in a different package within the JVM runtime. See run shell script -# for instructions on how to run this test. - - -if [ "${TESTJAVA}" = "" ] -then - echo "TESTJAVA not set. Test cannot execute. Failed." - exit 1 -fi - -if [ "${COMPILEJAVA}" = "" ] ; then - COMPILEJAVA="${TESTJAVA}" -fi - - -OS=`uname -s` -# Need to determine the classpath separator and filepath separator based on the -# operating system. -case "$OS" in -SunOS | Linux | Darwin | AIX ) - PS=":" ;; -Windows* | CYGWIN* ) - PS=";" ;; -* ) - echo "Unrecognized system!" - exit 1 ;; -esac - -JAVA=${TESTJAVA}/bin/java -JAVAC=${COMPILEJAVA}/bin/javac -MKDIR=mkdir -RDEL="rm -r" - -if [ -d ${TESTCLASSES}/oclasses ] -then - ${RDEL} ${TESTCLASSES}/oclasses -fi -if [ -d ${TESTCLASSES}/nclasses ] -then - ${RDEL} ${TESTCLASSES}/nclasses -fi -if [ -d ${TESTCLASSES}/share ] -then - ${RDEL} ${TESTCLASSES}/share -fi -if [ -f ${TESTCLASSES}/stream.ser ] -then - ${RDEL} ${TESTCLASSES}/stream.ser -fi - -mkdir ${TESTCLASSES}/oclasses -mkdir ${TESTCLASSES}/share -mkdir ${TESTCLASSES}/nclasses - -# Build sources -set -e -${JAVAC} ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d ${TESTCLASSES}/share \ - ${TESTSRC}/extension/ExtendedObjectInputStream.java -CLASSPATH=${TESTCLASSES}/share; export CLASSPATH; -${JAVAC} ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d ${TESTCLASSES}/oclasses \ - ${TESTSRC}/test/SerialDriver.java -CLASSPATH=${TESTCLASSES}/share; export CLASSPATH; -${JAVAC} ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d ${TESTCLASSES}/nclasses \ - ${TESTSRC}/install/SerialDriver.java - -# Run Case 1. Map test.SerialDriver within stream to install.SerialDriver. -CLASSPATH="${TESTCLASSES}/oclasses${PS}${TESTCLASSES}/share"; export CLASSPATH; -${JAVA} ${TESTVMOPTS} test.SerialDriver -s -CLASSPATH="${TESTCLASSES}/nclasses${PS}${TESTCLASSES}/share"; export CLASSPATH; -${JAVA} ${TESTVMOPTS} install.SerialDriver -d -rm stream.ser - -# Run Case 2. Map install.SerialDriver within stream to test.SerialDriver. -CLASSPATH="${TESTCLASSES}/nclasses${PS}${TESTCLASSES}/share"; export CLASSPATH; -${JAVA} ${TESTVMOPTS} install.SerialDriver -s -CLASSPATH="${TESTCLASSES}/oclasses${PS}${TESTCLASSES}/share"; export CLASSPATH; -${JAVA} ${TESTVMOPTS} test.SerialDriver -d --- old/test/java/io/Serializable/maskSyntheticModifier/run.sh 2017-05-25 21:20:19.495529056 -0700 +++ /dev/null 2017-05-26 01:02:49.226221427 -0700 @@ -1,49 +0,0 @@ -# -# Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. -# 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. -# -# 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). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# @test -# @bug 4897937 -# @summary Verify that the presence of the JVM_ACC_SYNTHETIC bit in the -# modifiers of fields and methods does not affect default -# serialVersionUID calculation. - -if [ "${TESTJAVA}" = "" ] -then - echo "TESTJAVA not set. Test cannot execute. Failed." -exit 1 -fi - -if [ "${COMPILEJAVA}" = "" ] ; then - COMPILEJAVA="${TESTJAVA}" -fi - -if [ "${TESTSRC}" = "" ] -then - TESTSRC="." -fi - -set -ex -cp ${TESTSRC}/Foo.class . -${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . ${TESTSRC}/Test.java -${TESTJAVA}/bin/java ${TESTVMOPTS} Test -rm -f *.class --- old/test/java/io/Serializable/packageAccess/run.sh 2017-05-25 21:20:19.803529073 -0700 +++ /dev/null 2017-05-26 01:02:49.226221427 -0700 @@ -1,54 +0,0 @@ -# -# Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. -# 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. -# -# 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). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# @test -# @bug 4765255 -# @summary Verify proper functioning of package equality checks used to -# determine accessibility of superclass constructor and inherited -# writeReplace/readResolve methods. - -if [ "${TESTJAVA}" = "" ] -then - echo "TESTJAVA not set. Test cannot execute. Failed." -exit 1 -fi - -if [ "${COMPILEJAVA}" = "" ] ; then - COMPILEJAVA="${TESTJAVA}" -fi - -if [ "${TESTSRC}" = "" ] -then - TESTSRC="." -fi - -set -ex - -${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . \ - ${TESTSRC}/A.java ${TESTSRC}/B.java ${TESTSRC}/C.java ${TESTSRC}/D.java \ - ${TESTSRC}/Test.java -${COMPILEJAVA}/bin/jar ${TESTTOOLVMOPTS} cf foo.jar B.class D.class -rm -f B.class D.class - -${TESTJAVA}/bin/java ${TESTVMOPTS} Test -rm -f *.class *.jar --- old/test/java/io/Serializable/resolveClass/consTest/run.sh 2017-05-25 21:20:20.142529092 -0700 +++ /dev/null 2017-05-26 01:02:49.226221427 -0700 @@ -1,53 +0,0 @@ -# -# Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. -# 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. -# -# 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). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# @test -# @bug 4413434 -# @summary Verify that generated java.lang.reflect implementation classes do -# not interfere with serialization's class resolution mechanism. - -if [ "${TESTJAVA}" = "" ] -then - echo "TESTJAVA not set. Test cannot execute. Failed." -exit 1 -fi - -if [ "${COMPILEJAVA}" = "" ] ; then - COMPILEJAVA="${TESTJAVA}" -fi - -if [ "${TESTSRC}" = "" ] -then - TESTSRC="." -fi - -set -ex - -rm -f *.class *.jar -${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . ${TESTSRC}/Boot.java -${COMPILEJAVA}/bin/jar ${TESTTOOLVMOPTS} cf boot.jar *.class -rm -f *.class -${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -classpath boot.jar -d . \ - ${TESTSRC}/Test.java -${TESTJAVA}/bin/java ${TESTVMOPTS} -Xbootclasspath/a:boot.jar Test -rm -f *.class *.jar --- old/test/java/io/Serializable/resolveClass/deserializeButton/run.sh 2017-05-25 21:20:20.513529114 -0700 +++ /dev/null 2017-05-26 01:02:49.226221427 -0700 @@ -1,54 +0,0 @@ -# -# Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. -# 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. -# -# 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). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# @test -# @bug 4413434 -# @summary Verify that class loaded outside of application class loader is -# correctly resolved during deserialization when read in by custom -# readObject() method of a bootstrap class (in this case, -# java.util.Vector). - -if [ "${TESTJAVA}" = "" ] -then - echo "TESTJAVA not set. Test cannot execute. Failed." -exit 1 -fi - -if [ "${COMPILEJAVA}" = "" ] ; then - COMPILEJAVA="${TESTJAVA}" -fi - -if [ "${TESTSRC}" = "" ] -then - TESTSRC="." -fi - -set -ex - -rm -f *.class *.jar -${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . ${TESTSRC}/Foo.java -${COMPILEJAVA}/bin/jar ${TESTTOOLVMOPTS} cf cb.jar *.class -rm -f *.class -${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . ${TESTSRC}/Test.java -${TESTJAVA}/bin/java ${TESTVMOPTS} Test -rm -f *.class *.jar --- old/test/java/io/Serializable/serialver/classpath/run.sh 2017-05-25 21:20:20.829529132 -0700 +++ /dev/null 2017-05-26 01:02:49.226221427 -0700 @@ -1,64 +0,0 @@ -# -# Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. -# 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. -# -# 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). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# @test -# @bug 4035147 4785472 -# @summary Test the use of the -classpath switch in the serialver application. -# @author Naveen Sanjeeva -# -# @build Test -# @run shell run.sh - -# set a few environment variables so that the shell-script can run stand-alone -# in the source directory - -if [ "${TESTSRC}" = "" ] ; then - TESTSRC="." -fi -if [ "${TESTCLASSES}" = "" ] ; then - TESTCLASSES="." -fi -if [ "${TESTJAVA}" = "" ] ; then - echo "TESTJAVA not set. Test cannot execute." - echo "FAILED!!!" - exit 1 -fi - -# set platform-dependent variables -OS=`uname -s` -case "$OS" in - SunOS | Linux | Darwin | AIX ) - PS=":" ;; - Windows* | CYGWIN* ) - PS=";" ;; - * ) - echo "Unrecognized system!" - exit 1 ;; -esac - -# the test code - -echo "Using the classpath .${PS}${TESTCLASSES}" -${TESTJAVA}/bin/serialver -classpath ".${PS}${TESTCLASSES}" serialver.Test - -exit $? --- old/test/java/io/Serializable/serialver/nested/run.sh 2017-05-25 21:20:21.213529153 -0700 +++ /dev/null 2017-05-26 01:02:49.226221427 -0700 @@ -1,64 +0,0 @@ -# -# Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. -# 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. -# -# 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). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# @test -# @bug 4312217 4785473 -# @summary Test the use of the -classpath switch in the serialver application. -# @author Naveen Sanjeeva -# -# @build Test -# @run shell run.sh - -# set a few environment variables so that the shell-script can run stand-alone -# in the source directory - -if [ "${TESTSRC}" = "" ] ; then - TESTSRC="." -fi -if [ "${TESTCLASSES}" = "" ] ; then - TESTCLASSES="." -fi -if [ "${TESTJAVA}" = "" ] ; then - echo "TESTJAVA not set. Test cannot execute." - echo "FAILED!!!" - exit 1 -fi - -# set platform-dependent variables -OS=`uname -s` -case "$OS" in - SunOS | Linux | Darwin | AIX ) - PS=":" ;; - Windows* | CYGWIN* ) - PS=";" ;; - * ) - echo "Unrecognized system!" - exit 1 ;; -esac - -# the test code - -echo "Using the classpath .${PS}${TESTCLASSES}" -${TESTJAVA}/bin/serialver -classpath ".${PS}${TESTCLASSES}" 'serialver.Test.Test1.Test2' - -exit $? --- old/test/java/io/Serializable/subclass/run.sh 2017-05-25 21:20:21.567529174 -0700 +++ /dev/null 2017-05-26 01:02:49.226221427 -0700 @@ -1,30 +0,0 @@ -# -# Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. -# 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. -# -# 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). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# -# @bug 4100915 -mkdir classes -javac -d classes *.java -java ${TESTVMOPTS} -classpath classes -Djava.policy=Allow.policy Test -# ENABLE next line when new method for invoking a main with a SecureClassLoader is known -#java -classpath classes -Djava.policy=NotAllow.policy Test -expectSecurityException --- old/test/java/io/Serializable/superclassDataLoss/run.sh 2017-05-25 21:20:21.891529192 -0700 +++ /dev/null 2017-05-26 01:02:49.226221427 -0700 @@ -1,56 +0,0 @@ -# -# Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. -# 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. -# -# 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). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# @test -# @bug 4325590 -# @summary Verify that superclass data is not lost when incoming superclass -# descriptor is matched with local class that is not a superclass of -# the deserialized instance's class. - -if [ "${TESTJAVA}" = "" ] -then - echo "TESTJAVA not set. Test cannot execute. Failed." -exit 1 -fi - -if [ "${COMPILEJAVA}" = "" ] ; then - COMPILEJAVA="${TESTJAVA}" -fi - -if [ "${TESTSRC}" = "" ] -then - TESTSRC="." -fi - -set -ex - -${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . \ - ${TESTSRC}/A.java ${TESTSRC}/B.java -${COMPILEJAVA}/bin/jar ${TESTTOOLVMOPTS} cf cb1.jar A.class B.class -cp cb1.jar cb2.jar -rm -f A.class B.class - -${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . \ - ${TESTSRC}/Test.java -${TESTJAVA}/bin/java ${TESTVMOPTS} Test -rm -f *.class *.jar --- old/test/java/io/Serializable/unnamedPackageSwitch/run.sh 2017-05-25 21:20:22.279529214 -0700 +++ /dev/null 2017-05-26 01:02:49.226221427 -0700 @@ -1,49 +0,0 @@ -# -# Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. -# 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. -# -# 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). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# @test -# @bug 4348213 -# @summary Verify that deserialization allows an incoming class descriptor -# representing a class in the unnamed package to be resolved to a -# local class with the same name in a named package, and vice-versa. - -if [ "${TESTJAVA}" = "" ] -then - echo "TESTJAVA not set. Test cannot execute. Failed." -exit 1 -fi - -if [ "${COMPILEJAVA}" = "" ] ; then - COMPILEJAVA="${TESTJAVA}" -fi - -if [ "${TESTSRC}" = "" ] -then - TESTSRC="." -fi - -set -ex - -${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . \ - ${TESTSRC}/A.java ${TESTSRC}/Test.java -${TESTJAVA}/bin/java ${TESTVMOPTS} Test