--- old/test/java/io/Serializable/class/NonSerialA_1.java 2017-06-01 01:19:52.297492824 -0700 +++ /dev/null 2017-05-31 08:30:51.413688597 -0700 @@ -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 2017-05-31 08:30:51.413688597 -0700 +++ new/test/java/io/Serializable/class/NonSerialA_1/A.java 2017-06-01 01:19:51.689492852 -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; +}; --- old/test/java/io/Serializable/class/NonSerialA_2.java 2017-06-01 01:19:52.969492794 -0700 +++ /dev/null 2017-05-31 08:30:51.413688597 -0700 @@ -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 2017-05-31 08:30:51.413688597 -0700 +++ new/test/java/io/Serializable/class/NonSerialA_2/A.java 2017-06-01 01:19:52.650492808 -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; +}; --- old/test/java/io/Serializable/class/run.sh 2017-06-01 01:19:53.711492760 -0700 +++ /dev/null 2017-05-31 08:30:51.413688597 -0700 @@ -1,129 +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. -# - -# @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 [ "${TESTSRC}" = "" ] -then -TESTSRC="." -fi - -${TESTJAVA}/bin/javac -d . ${TESTSRC}/Test.java - -echo Write NonSerial1, Read NonSerial1 -rm -f A.java -cp ${TESTSRC}/NonSerialA_1.java A.java -${TESTJAVA}/bin/javac A.java -${TESTJAVA}/bin/java Test -s A -${TESTJAVA}/bin/java Test -d -echo - -echo Write NonSerial1, Read NonSerial2 -rm -f A.java -cp ${TESTSRC}/NonSerialA_1.java A.java -${TESTJAVA}/bin/javac A.java -${TESTJAVA}/bin/java Test -s A -rm -f A.java -cp ${TESTSRC}/NonSerialA_2.java A.java -${TESTJAVA}/bin/javac A.java -${TESTJAVA}/bin/java Test -d -echo - -echo Write NonSerial1, Read Serial1 -rm -f A.java -cp ${TESTSRC}/NonSerialA_1.java A.java -${TESTJAVA}/bin/javac A.java -${TESTJAVA}/bin/java Test -s A -rm -f A.java -cp ${TESTSRC}/SerialA_1.java A.java -${TESTJAVA}/bin/javac A.java -${TESTJAVA}/bin/java Test -d -echo - -echo Write Serial1, Read NonSerial1 -rm -f A.java -cp ${TESTSRC}/SerialA_1.java A.java -${TESTJAVA}/bin/javac A.java -${TESTJAVA}/bin/java Test -s A -rm -f A.java -cp ${TESTSRC}/NonSerialA_1.java A.java -${TESTJAVA}/bin/javac A.java -${TESTJAVA}/bin/java Test -doe -echo - -echo Write Serial1, Read Serial2 -rm -f A.java -cp ${TESTSRC}/SerialA_1.java A.java -${TESTJAVA}/bin/javac A.java -${TESTJAVA}/bin/java Test -s A -rm -f A.java -cp ${TESTSRC}/SerialA_2.java A.java -${TESTJAVA}/bin/javac A.java -${TESTJAVA}/bin/java Test -d -echo - -echo Write Serial2, Read Serial1 -rm -f A.java -cp ${TESTSRC}/SerialA_2.java A.java -${TESTJAVA}/bin/javac A.java -${TESTJAVA}/bin/java Test -s A -rm -f A.java -cp ${TESTSRC}/SerialA_1.java A.java -${TESTJAVA}/bin/javac A.java -${TESTJAVA}/bin/java Test -d -echo - -echo Write Serial1, Read Serial3 -rm -f A.java -cp ${TESTSRC}/SerialA_1.java A.java -${TESTJAVA}/bin/javac A.java -${TESTJAVA}/bin/java Test -s A -rm -f A.java -cp ${TESTSRC}/SerialA_3.java A.java -${TESTJAVA}/bin/javac A.java -${TESTJAVA}/bin/java Test -de -echo - -echo Write Serial3, Read Serial1 -rm -f A.java -cp ${TESTSRC}/SerialA_3.java A.java -${TESTJAVA}/bin/javac A.java -${TESTJAVA}/bin/java Test -s A -rm -f A.java -cp ${TESTSRC}/SerialA_1.java A.java -${TESTJAVA}/bin/javac A.java -${TESTJAVA}/bin/java Test -de -echo - -echo Passed --- /dev/null 2017-05-31 08:30:51.413688597 -0700 +++ new/test/java/io/Serializable/class/NonSerializableTest.java 2017-06-01 01:19:53.316492778 -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 + new String[][] {new String[] {"NonSerialA_1", "-cp", ".", "TestEntry", "-s", "A"}}, + new String[][] {new String[] {"NonSerialA_1", "-cp", ".", "TestEntry", "-d"}}, + + // Write NonSerial1, Read NonSerial2 + new String[][] {new String[] {"NonSerialA_1", "-cp", ".", "TestEntry", "-s", "A"}}, + new String[][] {new String[] {"NonSerialA_2", "-cp", ".", "TestEntry", "-d"}}, + + // Write NonSerial1, Read Serial1 + new String[][] {new String[] {"NonSerialA_1", "-cp", ".", "TestEntry", "-s", "A"}}, + new String[][] {new String[] {"SerialA_1", "-cp", ".", "TestEntry", "-d"}}, + + // Write Serial1, Read NonSerial1 + new String[][] {new String[] {"SerialA_1", "-cp", ".", "TestEntry", "-s", "A"}}, + new String[][] {new String[] {"NonSerialA_1", "-cp", ".", "TestEntry", "-doe"}}, + + // Write Serial1, Read Serial2 + new String[][] {new String[] {"SerialA_1", "-cp", ".", "TestEntry", "-s", "A"}}, + new String[][] {new String[] {"SerialA_2", "-cp", ".", "TestEntry", "-d"}}, + + // Write Serial2, Read Serial1 + new String[][] {new String[] {"SerialA_2", "-cp", ".", "TestEntry", "-s", "A"}}, + new String[][] {new String[] {"SerialA_1", "-cp", ".", "TestEntry", "-d"}}, + + // Write Serial1, Read Serial3 + new String[][] {new String[] {"SerialA_1", "-cp", ".", "TestEntry", "-s", "A"}}, + new String[][] {new String[] {"SerialA_3", "-cp", ".", "TestEntry", "-de"}}, + + // Write Serial3, Read Serial1 + new String[][] {new String[] {"SerialA_3", "-cp", ".", "TestEntry", "-s", "A"}}, + new String[][] {new String[] {"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"); + } +} --- old/test/java/io/Serializable/class/SerialA_1.java 2017-06-01 01:19:54.627492718 -0700 +++ /dev/null 2017-05-31 08:30:51.413688597 -0700 @@ -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 2017-05-31 08:30:51.413688597 -0700 +++ new/test/java/io/Serializable/class/SerialA_1/A.java 2017-06-01 01:19:54.286492733 -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; +}; --- old/test/java/io/Serializable/class/SerialA_2.java 2017-06-01 01:19:55.366492684 -0700 +++ /dev/null 2017-05-31 08:30:51.413688597 -0700 @@ -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 2017-05-31 08:30:51.413688597 -0700 +++ new/test/java/io/Serializable/class/SerialA_2/A.java 2017-06-01 01:19:54.967492702 -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; +}; --- old/test/java/io/Serializable/class/SerialA_3.java 2017-06-01 01:19:56.016492654 -0700 +++ /dev/null 2017-05-31 08:30:51.413688597 -0700 @@ -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 2017-05-31 08:30:51.413688597 -0700 +++ new/test/java/io/Serializable/class/SerialA_3/A.java 2017-06-01 01:19:55.620492672 -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; +}; --- old/test/java/io/Serializable/class/Test.java 2017-06-01 01:19:56.518492631 -0700 +++ /dev/null 2017-05-31 08:30:51.413688597 -0700 @@ -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 2017-05-31 08:30:51.413688597 -0700 +++ new/test/java/io/Serializable/class/TestEntry.java 2017-06-01 01:19:56.215492645 -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"); + } + } +} --- old/test/java/io/Serializable/class/SerialA.java 2017-06-01 01:19:57.170492602 -0700 +++ /dev/null 2017-05-31 08:30:51.413688597 -0700 @@ -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; -};