1 # 2 # Copyright (c) 1998, 2001, Oracle and/or its affiliates. All rights reserved. 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 # 5 # This code is free software; you can redistribute it and/or modify it 6 # under the terms of the GNU General Public License version 2 only, as 7 # published by the Free Software Foundation. 8 # 9 # This code is distributed in the hope that it will be useful, but WITHOUT 10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 # version 2 for more details (a copy is included in the LICENSE file that 13 # accompanied this code). 14 # 15 # You should have received a copy of the GNU General Public License version 16 # 2 along with this work; if not, write to the Free Software Foundation, 17 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 # 19 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 # or visit www.oracle.com if you need additional information or have any 21 # questions. 22 # 23 24 # @test 25 # @bug 4075221 26 # @run shell/timeout=300 run.sh 27 # @summary Enable serialize of nonSerializable Class descriptor. 28 29 set -ex 30 31 if [ "${TESTJAVA}" = "" ] 32 then 33 echo "TESTJAVA not set. Test cannot execute. Failed." 34 exit 1 35 fi 36 37 if [ "${TESTSRC}" = "" ] 38 then 39 TESTSRC="." 40 fi 41 42 ${TESTJAVA}/bin/javac -d . ${TESTSRC}/Test.java 43 44 echo Write NonSerial1, Read NonSerial1 45 rm -f A.java 46 cp ${TESTSRC}/NonSerialA_1.java A.java 47 ${TESTJAVA}/bin/javac A.java 48 ${TESTJAVA}/bin/java Test -s A 49 ${TESTJAVA}/bin/java Test -d 50 echo 51 52 echo Write NonSerial1, Read NonSerial2 53 rm -f A.java 54 cp ${TESTSRC}/NonSerialA_1.java A.java 55 ${TESTJAVA}/bin/javac A.java 56 ${TESTJAVA}/bin/java Test -s A 57 rm -f A.java 58 cp ${TESTSRC}/NonSerialA_2.java A.java 59 ${TESTJAVA}/bin/javac A.java 60 ${TESTJAVA}/bin/java Test -d 61 echo 62 63 echo Write NonSerial1, Read Serial1 64 rm -f A.java 65 cp ${TESTSRC}/NonSerialA_1.java A.java 66 ${TESTJAVA}/bin/javac A.java 67 ${TESTJAVA}/bin/java Test -s A 68 rm -f A.java 69 cp ${TESTSRC}/SerialA_1.java A.java 70 ${TESTJAVA}/bin/javac A.java 71 ${TESTJAVA}/bin/java Test -d 72 echo 73 74 echo Write Serial1, Read NonSerial1 75 rm -f A.java 76 cp ${TESTSRC}/SerialA_1.java A.java 77 ${TESTJAVA}/bin/javac A.java 78 ${TESTJAVA}/bin/java Test -s A 79 rm -f A.java 80 cp ${TESTSRC}/NonSerialA_1.java A.java 81 ${TESTJAVA}/bin/javac A.java 82 ${TESTJAVA}/bin/java Test -doe 83 echo 84 85 echo Write Serial1, Read Serial2 86 rm -f A.java 87 cp ${TESTSRC}/SerialA_1.java A.java 88 ${TESTJAVA}/bin/javac A.java 89 ${TESTJAVA}/bin/java Test -s A 90 rm -f A.java 91 cp ${TESTSRC}/SerialA_2.java A.java 92 ${TESTJAVA}/bin/javac A.java 93 ${TESTJAVA}/bin/java Test -d 94 echo 95 96 echo Write Serial2, Read Serial1 97 rm -f A.java 98 cp ${TESTSRC}/SerialA_2.java A.java 99 ${TESTJAVA}/bin/javac A.java 100 ${TESTJAVA}/bin/java Test -s A 101 rm -f A.java 102 cp ${TESTSRC}/SerialA_1.java A.java 103 ${TESTJAVA}/bin/javac A.java 104 ${TESTJAVA}/bin/java Test -d 105 echo 106 107 echo Write Serial1, Read Serial3 108 rm -f A.java 109 cp ${TESTSRC}/SerialA_1.java A.java 110 ${TESTJAVA}/bin/javac A.java 111 ${TESTJAVA}/bin/java Test -s A 112 rm -f A.java 113 cp ${TESTSRC}/SerialA_3.java A.java 114 ${TESTJAVA}/bin/javac A.java 115 ${TESTJAVA}/bin/java Test -de 116 echo 117 118 echo Write Serial3, Read Serial1 119 rm -f A.java 120 cp ${TESTSRC}/SerialA_3.java A.java 121 ${TESTJAVA}/bin/javac A.java 122 ${TESTJAVA}/bin/java Test -s A 123 rm -f A.java 124 cp ${TESTSRC}/SerialA_1.java A.java 125 ${TESTJAVA}/bin/javac A.java 126 ${TESTJAVA}/bin/java Test -de 127 echo 128 129 echo Passed | 1 /* 2 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * @test 26 * @bug 4075221 27 * @library /test/lib 28 * @build jdk.test.lib.compiler.* 29 * @build jdk.test.lib.process.* 30 * @run testng/timeout=300 NonSerializableTest 31 * @summary Enable serialize of nonSerializable Class descriptor. 32 */ 33 34 import java.nio.file.Paths; 35 import java.util.Arrays; 36 37 import org.testng.annotations.DataProvider; 38 import org.testng.annotations.BeforeClass; 39 import org.testng.annotations.Test; 40 import static org.testng.Assert.assertTrue; 41 import static org.testng.Assert.assertEquals; 42 43 import jdk.test.lib.compiler.CompilerUtils; 44 import jdk.test.lib.process.ProcessTools; 45 46 47 public class NonSerializableTest { 48 49 @BeforeClass 50 public void setup() throws Exception { 51 boolean b = CompilerUtils.compile( 52 Paths.get(System.getProperty("test.src"), "TestEntry.java"), 53 Paths.get(System.getProperty("user.dir"))); 54 assertTrue(b, "Compilation failed"); 55 } 56 57 @DataProvider 58 public Object[][] provider() { 59 return new String[][][] { 60 // Write NonSerial1, Read NonSerial1 61 new String[][] {new String[] {"NonSerialA_1", "-cp", ".", "TestEntry", "-s", "A"}}, 62 new String[][] {new String[] {"NonSerialA_1", "-cp", ".", "TestEntry", "-d"}}, 63 64 // Write NonSerial1, Read NonSerial2 65 new String[][] {new String[] {"NonSerialA_1", "-cp", ".", "TestEntry", "-s", "A"}}, 66 new String[][] {new String[] {"NonSerialA_2", "-cp", ".", "TestEntry", "-d"}}, 67 68 // Write NonSerial1, Read Serial1 69 new String[][] {new String[] {"NonSerialA_1", "-cp", ".", "TestEntry", "-s", "A"}}, 70 new String[][] {new String[] {"SerialA_1", "-cp", ".", "TestEntry", "-d"}}, 71 72 // Write Serial1, Read NonSerial1 73 new String[][] {new String[] {"SerialA_1", "-cp", ".", "TestEntry", "-s", "A"}}, 74 new String[][] {new String[] {"NonSerialA_1", "-cp", ".", "TestEntry", "-doe"}}, 75 76 // Write Serial1, Read Serial2 77 new String[][] {new String[] {"SerialA_1", "-cp", ".", "TestEntry", "-s", "A"}}, 78 new String[][] {new String[] {"SerialA_2", "-cp", ".", "TestEntry", "-d"}}, 79 80 // Write Serial2, Read Serial1 81 new String[][] {new String[] {"SerialA_2", "-cp", ".", "TestEntry", "-s", "A"}}, 82 new String[][] {new String[] {"SerialA_1", "-cp", ".", "TestEntry", "-d"}}, 83 84 // Write Serial1, Read Serial3 85 new String[][] {new String[] {"SerialA_1", "-cp", ".", "TestEntry", "-s", "A"}}, 86 new String[][] {new String[] {"SerialA_3", "-cp", ".", "TestEntry", "-de"}}, 87 88 // Write Serial3, Read Serial1 89 new String[][] {new String[] {"SerialA_3", "-cp", ".", "TestEntry", "-s", "A"}}, 90 new String[][] {new String[] {"SerialA_1", "-cp", ".", "TestEntry", "-de"}}, 91 }; 92 } 93 94 @Test(dataProvider="provider") 95 public void test(String[] args) throws Exception { 96 boolean b = CompilerUtils.compile(Paths.get(System.getProperty("test.src"), args[0]), 97 Paths.get(System.getProperty("user.dir"))); 98 assertTrue(b, "Compilation failed"); 99 String params[] = Arrays.copyOfRange(args, 1, args.length); 100 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(params); 101 Process p = ProcessTools.startProcess("Serializable Test", pb); 102 int exitValue = p.waitFor(); 103 assertEquals(exitValue, 0, "Test failed"); 104 } 105 } |