8166142: Refactor java.io.serialization shell tests to java
authormli
Wed, 31 May 2017 20:01:33 -0700
changeset 45295 c2764290902a
parent 45294 782df98c0359
child 45296 ae7b350fabcb
8166142: Refactor java.io.serialization shell tests to java Reviewed-by: rriggs
jdk/test/java/io/Serializable/evolution/AddedExternField/run.sh
jdk/test/java/io/Serializable/evolution/RenamePackage/RenamePackageTest.java
jdk/test/java/io/Serializable/evolution/RenamePackage/run.sh
jdk/test/java/io/Serializable/maskSyntheticModifier/MaskSyntheticModifierTest.java
jdk/test/java/io/Serializable/maskSyntheticModifier/Test.java
jdk/test/java/io/Serializable/maskSyntheticModifier/run.sh
jdk/test/java/io/Serializable/packageAccess/PackageAccessTest.java
jdk/test/java/io/Serializable/packageAccess/Test.java
jdk/test/java/io/Serializable/packageAccess/run.sh
jdk/test/java/io/Serializable/resolveClass/consTest/ConsTest.java
jdk/test/java/io/Serializable/resolveClass/consTest/SetupJar.java
jdk/test/java/io/Serializable/resolveClass/consTest/Test.java
jdk/test/java/io/Serializable/resolveClass/consTest/run.sh
jdk/test/java/io/Serializable/resolveClass/deserializeButton/DeserializeButtonTest.java
jdk/test/java/io/Serializable/resolveClass/deserializeButton/Test.java
jdk/test/java/io/Serializable/resolveClass/deserializeButton/run.sh
jdk/test/java/io/Serializable/serialver/classpath/ClasspathTest.java
jdk/test/java/io/Serializable/serialver/classpath/Test.java
jdk/test/java/io/Serializable/serialver/classpath/run.sh
jdk/test/java/io/Serializable/serialver/nested/NestedTest.java
jdk/test/java/io/Serializable/serialver/nested/Test.java
jdk/test/java/io/Serializable/serialver/nested/run.sh
jdk/test/java/io/Serializable/subclass/Allow.policy
jdk/test/java/io/Serializable/subclass/SubclassTest.java
jdk/test/java/io/Serializable/subclass/Test.java
jdk/test/java/io/Serializable/subclass/run.sh
jdk/test/java/io/Serializable/superclassDataLoss/SuperclassDataLossTest.java
jdk/test/java/io/Serializable/superclassDataLoss/Test.java
jdk/test/java/io/Serializable/superclassDataLoss/run.sh
jdk/test/java/io/Serializable/unnamedPackageSwitch/Test.java
jdk/test/java/io/Serializable/unnamedPackageSwitch/UnnamedPackageSwitchTest.java
jdk/test/java/io/Serializable/unnamedPackageSwitch/run.sh
--- a/jdk/test/java/io/Serializable/evolution/AddedExternField/run.sh	Wed May 31 13:14:34 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/evolution/RenamePackage/RenamePackageTest.java	Wed May 31 20:01:33 2017 -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 {
+        setup();
+
+        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 setup() 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");
+        }
+    }
+}
--- a/jdk/test/java/io/Serializable/evolution/RenamePackage/run.sh	Wed May 31 13:14:34 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/maskSyntheticModifier/MaskSyntheticModifierTest.java	Wed May 31 20:01:33 2017 -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);
+    }
+}
--- a/jdk/test/java/io/Serializable/maskSyntheticModifier/Test.java	Wed May 31 13:14:34 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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);
-        }
-    }
-}
--- a/jdk/test/java/io/Serializable/maskSyntheticModifier/run.sh	Wed May 31 13:14:34 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/packageAccess/PackageAccessTest.java	Wed May 31 20:01:33 2017 -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();
+
+        try (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);
+        }
+    }
+
+    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);
+        }
+    }
+}
--- a/jdk/test/java/io/Serializable/packageAccess/Test.java	Wed May 31 13:14:34 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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);
-        }
-    }
-}
--- a/jdk/test/java/io/Serializable/packageAccess/run.sh	Wed May 31 13:14:34 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/resolveClass/consTest/ConsTest.java	Wed May 31 20:01:33 2017 -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	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/resolveClass/consTest/SetupJar.java	Wed May 31 20:01:33 2017 -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"));
+    }
+}
--- a/jdk/test/java/io/Serializable/resolveClass/consTest/Test.java	Wed May 31 13:14:34 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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 });
-        }
-    }
-}
--- a/jdk/test/java/io/Serializable/resolveClass/consTest/run.sh	Wed May 31 13:14:34 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/resolveClass/deserializeButton/DeserializeButtonTest.java	Wed May 31 20:01:33 2017 -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();
+
+        try (URLClassLoader ldr =
+            new URLClassLoader(new URL[]{ new URL("file:cb.jar") })) {
+            Runnable r = (Runnable) Class.forName("Foo", true, ldr).newInstance();
+            r.run();
+        }
+    }
+
+    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"));
+    }
+}
--- a/jdk/test/java/io/Serializable/resolveClass/deserializeButton/Test.java	Wed May 31 13:14:34 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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();
-    }
-}
--- a/jdk/test/java/io/Serializable/resolveClass/deserializeButton/run.sh	Wed May 31 13:14:34 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/serialver/classpath/ClasspathTest.java	Wed May 31 20:01:33 2017 -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");
+        }
+    }
+}
--- a/jdk/test/java/io/Serializable/serialver/classpath/Test.java	Wed May 31 13:14:34 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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;
-}
--- a/jdk/test/java/io/Serializable/serialver/classpath/run.sh	Wed May 31 13:14:34 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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 $?
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/serialver/nested/NestedTest.java	Wed May 31 20:01:33 2017 -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.");
+        }
+    }
+}
--- a/jdk/test/java/io/Serializable/serialver/nested/Test.java	Wed May 31 13:14:34 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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;
-        }
-    }
-}
--- a/jdk/test/java/io/Serializable/serialver/nested/run.sh	Wed May 31 13:14:34 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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 $?
--- a/jdk/test/java/io/Serializable/subclass/Allow.policy	Wed May 31 13:14:34 2017 -0700
+++ b/jdk/test/java/io/Serializable/subclass/Allow.policy	Wed May 31 20:01:33 2017 -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	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/subclass/SubclassTest.java	Wed May 31 20:01:33 2017 -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 exception 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();
+    }
+};
--- a/jdk/test/java/io/Serializable/subclass/Test.java	Wed May 31 13:14:34 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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();
-    }
-};
--- a/jdk/test/java/io/Serializable/subclass/run.sh	Wed May 31 13:14:34 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/superclassDataLoss/SuperclassDataLossTest.java	Wed May 31 20:01:33 2017 -0700
@@ -0,0 +1,121 @@
+/*
+ * 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;
+    private URLClassLoader ldr1;
+    private URLClassLoader ldr2;
+
+    MixedSuperclassStream(InputStream in, URLClassLoader ldr1,
+            URLClassLoader ldr2, boolean ldr1First) throws IOException {
+        super(in);
+        this.ldr1 = ldr1;
+        this.ldr2 = ldr2;
+        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, ldr1);
+            } else if (name.equals("B")) {
+                return Class.forName(name, true, ldr2);
+            }
+        } else {
+            if (name.equals("B")) {
+                return Class.forName(name, true, ldr1);
+            } else if (name.equals("A")) {
+                return Class.forName(name, true, ldr2);
+            }
+        }
+        return super.resolveClass(desc);
+    }
+}
+
+public class SuperclassDataLossTest {
+
+    public static void main(String[] args) throws Exception {
+        try (URLClassLoader ldr1 = new URLClassLoader(new URL[] { new URL("file:cb1.jar") });
+             URLClassLoader ldr2 = new URLClassLoader(new URL[] { new URL("file:cb2.jar") })) {
+            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, ldr1, ldr2, true);
+            test(bout, ldr1, ldr2, false);
+        }
+    }
+
+    private static void test(ByteArrayOutputStream bout, URLClassLoader ldr1,
+                             URLClassLoader ldr2, boolean ldr12A) throws Exception {
+        ByteArrayInputStream bin =
+            new ByteArrayInputStream(bout.toByteArray());
+        ObjectInputStream oin = new MixedSuperclassStream(bin, ldr1, ldr2, 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);
+    }
+}
--- a/jdk/test/java/io/Serializable/superclassDataLoss/Test.java	Wed May 31 13:14:34 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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();
-    }
-}
--- a/jdk/test/java/io/Serializable/superclassDataLoss/run.sh	Wed May 31 13:14:34 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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
--- a/jdk/test/java/io/Serializable/unnamedPackageSwitch/Test.java	Wed May 31 13:14:34 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/unnamedPackageSwitch/UnnamedPackageSwitchTest.java	Wed May 31 20:01:33 2017 -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();
+    }
+}
--- a/jdk/test/java/io/Serializable/unnamedPackageSwitch/run.sh	Wed May 31 13:14:34 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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