8180927: refactor ./java/io/Serializable/class/run.sh to java test
authormli
Mon, 05 Jun 2017 18:58:40 -0700
changeset 45389 213e7518bab8
parent 45388 6406324c5b40
child 45390 c3f2c4b3d980
8180927: refactor ./java/io/Serializable/class/run.sh to java test Reviewed-by: psandoz
jdk/test/java/io/Serializable/class/NonSerialA_1.java
jdk/test/java/io/Serializable/class/NonSerialA_1/A.java
jdk/test/java/io/Serializable/class/NonSerialA_2.java
jdk/test/java/io/Serializable/class/NonSerialA_2/A.java
jdk/test/java/io/Serializable/class/NonSerializableTest.java
jdk/test/java/io/Serializable/class/SerialA.java
jdk/test/java/io/Serializable/class/SerialA_1.java
jdk/test/java/io/Serializable/class/SerialA_1/A.java
jdk/test/java/io/Serializable/class/SerialA_2.java
jdk/test/java/io/Serializable/class/SerialA_2/A.java
jdk/test/java/io/Serializable/class/SerialA_3.java
jdk/test/java/io/Serializable/class/SerialA_3/A.java
jdk/test/java/io/Serializable/class/Test.java
jdk/test/java/io/Serializable/class/TestEntry.java
jdk/test/java/io/Serializable/class/run.sh
--- a/jdk/test/java/io/Serializable/class/NonSerialA_1.java	Mon Jun 05 18:02:51 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +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.
- */
-
-
-public class A {
-    int field1;
-};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/class/NonSerialA_1/A.java	Mon Jun 05 18:58:40 2017 -0700
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+
+
+public class A {
+    int field1;
+};
--- a/jdk/test/java/io/Serializable/class/NonSerialA_2.java	Mon Jun 05 18:02:51 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +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.
- */
-
-public class A {
-    int field1;
-    int field2;
-};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/class/NonSerialA_2/A.java	Mon Jun 05 18:58:40 2017 -0700
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+
+public class A {
+    int field1;
+    int field2;
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/class/NonSerializableTest.java	Mon Jun 05 18:58:40 2017 -0700
@@ -0,0 +1,105 @@
+/*
+ * 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 4075221
+ * @library /test/lib
+ * @build jdk.test.lib.compiler.*
+ * @build jdk.test.lib.process.*
+ * @run testng/timeout=300 NonSerializableTest
+ * @summary Enable serialize of nonSerializable Class descriptor.
+ */
+
+import java.nio.file.Paths;
+import java.util.Arrays;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertEquals;
+
+import jdk.test.lib.compiler.CompilerUtils;
+import jdk.test.lib.process.ProcessTools;
+
+
+public class NonSerializableTest {
+
+    @BeforeClass
+    public void setup() throws Exception {
+        boolean b = CompilerUtils.compile(
+                Paths.get(System.getProperty("test.src"), "TestEntry.java"),
+                Paths.get(System.getProperty("user.dir")));
+        assertTrue(b, "Compilation failed");
+    }
+
+    @DataProvider
+    public Object[][] provider() {
+        return new String[][][] {
+            // Write NonSerial1, Read NonSerial1
+            {{"NonSerialA_1", "-cp", ".", "TestEntry", "-s", "A"}},
+            {{"NonSerialA_1", "-cp", ".", "TestEntry", "-d"}},
+
+            // Write NonSerial1, Read NonSerial2
+            {{"NonSerialA_1", "-cp", ".", "TestEntry", "-s", "A"}},
+            {{"NonSerialA_2", "-cp", ".", "TestEntry", "-d"}},
+
+            // Write NonSerial1, Read Serial1
+            {{"NonSerialA_1", "-cp", ".", "TestEntry", "-s", "A"}},
+            {{"SerialA_1", "-cp", ".", "TestEntry", "-d"}},
+
+            // Write Serial1, Read NonSerial1
+            {{"SerialA_1", "-cp", ".", "TestEntry", "-s", "A"}},
+            {{"NonSerialA_1", "-cp", ".", "TestEntry", "-doe"}},
+
+            // Write Serial1, Read Serial2
+            {{"SerialA_1", "-cp", ".", "TestEntry", "-s", "A"}},
+            {{"SerialA_2", "-cp", ".", "TestEntry", "-d"}},
+
+            // Write Serial2, Read Serial1
+            {{"SerialA_2", "-cp", ".", "TestEntry", "-s", "A"}},
+            {{"SerialA_1", "-cp", ".", "TestEntry", "-d"}},
+
+            // Write Serial1, Read Serial3
+            {{"SerialA_1", "-cp", ".", "TestEntry", "-s", "A"}},
+            {{"SerialA_3", "-cp", ".", "TestEntry", "-de"}},
+
+            // Write Serial3, Read Serial1
+            {{"SerialA_3", "-cp", ".", "TestEntry", "-s", "A"}},
+            {{"SerialA_1", "-cp", ".", "TestEntry", "-de"}},
+        };
+    }
+
+    @Test(dataProvider="provider")
+    public void test(String[] args) throws Exception {
+        boolean b = CompilerUtils.compile(Paths.get(System.getProperty("test.src"), args[0]),
+                                          Paths.get(System.getProperty("user.dir")));
+        assertTrue(b, "Compilation failed");
+        String params[] = Arrays.copyOfRange(args, 1, args.length);
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(params);
+        Process p = ProcessTools.startProcess("Serializable Test", pb);
+        int exitValue = p.waitFor();
+        assertEquals(exitValue, 0, "Test failed");
+    }
+}
--- a/jdk/test/java/io/Serializable/class/SerialA.java	Mon Jun 05 18:02:51 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +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.
- */
-
-import java.io.Serializable;
-
-public class A implements Serializable {
-    int field1;
-};
--- a/jdk/test/java/io/Serializable/class/SerialA_1.java	Mon Jun 05 18:02:51 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +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.
- */
-
-import java.io.Serializable;
-
-public class A implements Serializable {
-    int field1;
-};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/class/SerialA_1/A.java	Mon Jun 05 18:58:40 2017 -0700
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+
+import java.io.Serializable;
+
+public class A implements Serializable {
+    int field1;
+};
--- a/jdk/test/java/io/Serializable/class/SerialA_2.java	Mon Jun 05 18:02:51 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +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.
- */
-
-import java.io.Serializable;
-
-public class A implements Serializable {
-    static final long serialVersionUID = 746945609796141988L;
-
-    int field1;
-    int field2;
-};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/class/SerialA_2/A.java	Mon Jun 05 18:58:40 2017 -0700
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+import java.io.Serializable;
+
+public class A implements Serializable {
+    static final long serialVersionUID = 746945609796141988L;
+
+    int field1;
+    int field2;
+};
--- a/jdk/test/java/io/Serializable/class/SerialA_3.java	Mon Jun 05 18:02:51 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +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.
- */
-
-import java.io.Serializable;
-
-/* THis class is purposely not compatible with previous versions of class.*/
-public class A implements Serializable {
-    int field1;
-    int field2;
-    int field3;
-};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/class/SerialA_3/A.java	Mon Jun 05 18:58:40 2017 -0700
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+import java.io.Serializable;
+
+/* THis class is purposely not compatible with previous versions of class.*/
+public class A implements Serializable {
+    int field1;
+    int field2;
+    int field3;
+};
--- a/jdk/test/java/io/Serializable/class/Test.java	Mon Jun 05 18:02:51 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 1998, 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 4075221
- * @summary Enable serialize of nonSerializable Class descriptor.
- */
-
-import java.io.*;
-
-class Test {
-    public static void main(String args[]) throws Exception {
-        File f = new File("tmp.ser");
-        if (args[0].compareTo("-s") == 0) {
-            FileOutputStream of = new FileOutputStream(f);
-            ObjectOutputStream oos = new ObjectOutputStream(of);
-            Class cl = Class.forName(args[1]);
-            oos.writeObject(cl);
-            if (ObjectStreamClass.lookup(cl) != null)
-                oos.writeObject(cl.newInstance());
-            oos.close();
-            System.out.println("Serialized Class " + cl.getName());
-        } else if (args[0].compareTo("-de") == 0) {
-            FileInputStream inf = new FileInputStream(f);
-            ObjectInputStream ois = new ObjectInputStream(inf);
-            Class cl = null;
-            try {
-                cl = (Class)ois.readObject();
-                throw new Error("Expected InvalidClassException to be thrown");
-            } catch (InvalidClassException e) {
-                System.out.println("Caught expected exception DeSerializing class " + e.getMessage());
-            }
-            ois.close();
-        } else if (args[0].compareTo("-doe") == 0) {
-            FileInputStream inf = new FileInputStream(f);
-            ObjectInputStream ois = new ObjectInputStream(inf);
-            Class cl = null;
-            cl = (Class)ois.readObject();
-            try {
-                ois.readObject();
-                throw new Error("Expected InvalidClassException to be thrown");
-            } catch (InvalidClassException e) {
-                System.out.println("Caught expected exception DeSerializing class " + e.getMessage());
-            }
-            ois.close();
-        } else if (args[0].compareTo("-d") == 0) {
-            FileInputStream inf = new FileInputStream(f);
-            ObjectInputStream ois = new ObjectInputStream(inf);
-            Class cl = (Class)ois.readObject();
-            try {
-                ois.readObject();
-            } catch (EOFException e) {
-            }
-            ois.close();
-            System.out.println("DeSerialized Class " + cl.getName());
-        }
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/class/TestEntry.java	Mon Jun 05 18:58:40 2017 -0700
@@ -0,0 +1,87 @@
+/*
+ * 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.
+ */
+
+/*
+ * @bug 4075221
+ * @summary Enable serialize of nonSerializable Class descriptor.
+ */
+
+import java.io.EOFException;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileInputStream;
+import java.io.InvalidClassException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamClass;
+
+class TestEntry {
+    public static void main(String args[]) throws Exception {
+        File f = new File("tmp.ser");
+        if (args[0].compareTo("-s") == 0) {
+            FileOutputStream of = new FileOutputStream(f);
+            ObjectOutputStream oos = new ObjectOutputStream(of);
+            Class cl = Class.forName(args[1]);
+            oos.writeObject(cl);
+            if (ObjectStreamClass.lookup(cl) != null)
+                oos.writeObject(cl.newInstance());
+            oos.close();
+            System.out.println("Serialized Class " + cl.getName());
+        } else if (args[0].compareTo("-de") == 0) {
+            FileInputStream inf = new FileInputStream(f);
+            ObjectInputStream ois = new ObjectInputStream(inf);
+            Class cl = null;
+            try {
+                cl = (Class)ois.readObject();
+                throw new Error("Expected InvalidClassException to be thrown");
+            } catch (InvalidClassException e) {
+                System.out.println("Caught expected exception DeSerializing class " + e.getMessage());
+            }
+            ois.close();
+        } else if (args[0].compareTo("-doe") == 0) {
+            FileInputStream inf = new FileInputStream(f);
+            ObjectInputStream ois = new ObjectInputStream(inf);
+            Class cl = null;
+            cl = (Class)ois.readObject();
+            try {
+                ois.readObject();
+                throw new Error("Expected InvalidClassException to be thrown");
+            } catch (InvalidClassException e) {
+                System.out.println("Caught expected exception DeSerializing class " + e.getMessage());
+            }
+            ois.close();
+        } else if (args[0].compareTo("-d") == 0) {
+            FileInputStream inf = new FileInputStream(f);
+            ObjectInputStream ois = new ObjectInputStream(inf);
+            Class cl = (Class)ois.readObject();
+            try {
+                ois.readObject();
+            } catch (EOFException e) {
+            }
+            ois.close();
+            System.out.println("DeSerialized Class " + cl.getName());
+        } else {
+            throw new RuntimeException("Unrecognized argument");
+        }
+    }
+}
--- a/jdk/test/java/io/Serializable/class/run.sh	Mon Jun 05 18:02:51 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,133 +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 4075221
-# @run shell/timeout=300 run.sh
-# @summary Enable serialize of nonSerializable Class descriptor.
-
-set -ex	
-
-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
-
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . ${TESTSRC}/Test.java
-
-echo Write NonSerial1, Read NonSerial1
-rm -f A.java     
-cp ${TESTSRC}/NonSerialA_1.java A.java
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} A.java
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test -s A
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test -d
-echo
-
-echo Write NonSerial1, Read NonSerial2
-rm -f A.java     
-cp ${TESTSRC}/NonSerialA_1.java A.java
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} A.java
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test -s A
-rm -f A.java     
-cp ${TESTSRC}/NonSerialA_2.java A.java
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} A.java
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test -d
-echo
-
-echo Write NonSerial1, Read Serial1
-rm -f A.java     
-cp ${TESTSRC}/NonSerialA_1.java A.java
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} A.java 
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test -s A
-rm -f A.java     
-cp ${TESTSRC}/SerialA_1.java A.java
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} A.java
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test -d
-echo
-
-echo Write Serial1, Read NonSerial1
-rm -f A.java     
-cp ${TESTSRC}/SerialA_1.java A.java
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} A.java 
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test -s A
-rm -f A.java     
-cp ${TESTSRC}/NonSerialA_1.java A.java
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} A.java
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test -doe
-echo
-
-echo Write Serial1, Read Serial2
-rm -f A.java     
-cp ${TESTSRC}/SerialA_1.java A.java
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} A.java 
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test -s A
-rm -f A.java     
-cp ${TESTSRC}/SerialA_2.java A.java
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} A.java
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test -d
-echo
-
-echo Write Serial2, Read Serial1
-rm -f A.java     
-cp ${TESTSRC}/SerialA_2.java A.java
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} A.java 
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test -s A
-rm -f A.java     
-cp ${TESTSRC}/SerialA_1.java A.java
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} A.java
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test -d
-echo
-
-echo Write Serial1, Read Serial3
-rm -f A.java     
-cp ${TESTSRC}/SerialA_1.java A.java
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} A.java 
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test -s A
-rm -f A.java     
-cp ${TESTSRC}/SerialA_3.java A.java
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} A.java
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test -de
-echo
-
-echo Write Serial3, Read Serial1
-rm -f A.java     
-cp ${TESTSRC}/SerialA_3.java A.java
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} A.java 
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test -s A
-rm -f A.java     
-cp ${TESTSRC}/SerialA_1.java A.java
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} A.java
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test -de
-echo
-
-echo Passed