author | lancea |
Thu, 14 Nov 2019 10:54:32 -0500 | |
changeset 59083 | 3e4d8b5856f3 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
15526
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
1 |
/* |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
2 |
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
4 |
* |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
8 |
* |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
13 |
* accompanied this code). |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
14 |
* |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
18 |
* |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
21 |
* questions. |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
22 |
*/ |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
23 |
import java.io.File; |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
24 |
import java.util.ArrayList; |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
25 |
import java.util.List; |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
26 |
|
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
27 |
/* |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
28 |
* @test |
16050
1eee624cddb3
8007297: [pack200] allow opcodes with InterfaceMethodRefs
ksrini
parents:
15526
diff
changeset
|
29 |
* @bug 8003549 8007297 |
15526
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
30 |
* @summary tests class files instruction formats introduced in JSR-335 |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
31 |
* @compile -XDignore.symbol.file Utils.java InstructionTests.java |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
32 |
* @run main InstructionTests |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
33 |
* @author ksrini |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
34 |
*/ |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
35 |
public class InstructionTests { |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
36 |
public static void main(String... args) throws Exception { |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
37 |
testInvokeOpCodes(); |
18594
b6a3c9f71ac8
8017463: [TEST_BUG] 2 tests from tools/pack200/ remain about 1 GB of data in work directory after execution
ksrini
parents:
17490
diff
changeset
|
38 |
Utils.cleanup(); |
15526
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
39 |
} |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
40 |
/* |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
41 |
* the following should produce invokestatic and invokespecial |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
42 |
* on InterfaceMethodRefs vs. MethodRefs, packer/unpacker should work |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
43 |
*/ |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
44 |
static void testInvokeOpCodes() throws Exception { |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
45 |
List<String> scratch = new ArrayList<>(); |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
46 |
final String fname = "A"; |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
47 |
String javaFileName = fname + Utils.JAVA_FILE_EXT; |
16050
1eee624cddb3
8007297: [pack200] allow opcodes with InterfaceMethodRefs
ksrini
parents:
15526
diff
changeset
|
48 |
scratch.add("interface I {"); |
15526
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
49 |
scratch.add(" default void forEach(){}"); |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
50 |
scratch.add(" static void next() {}"); |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
51 |
scratch.add("}"); |
16050
1eee624cddb3
8007297: [pack200] allow opcodes with InterfaceMethodRefs
ksrini
parents:
15526
diff
changeset
|
52 |
scratch.add("class A implements I {"); |
1eee624cddb3
8007297: [pack200] allow opcodes with InterfaceMethodRefs
ksrini
parents:
15526
diff
changeset
|
53 |
scratch.add(" public void forEach(Object o){"); |
1eee624cddb3
8007297: [pack200] allow opcodes with InterfaceMethodRefs
ksrini
parents:
15526
diff
changeset
|
54 |
scratch.add(" I.super.forEach();"); |
1eee624cddb3
8007297: [pack200] allow opcodes with InterfaceMethodRefs
ksrini
parents:
15526
diff
changeset
|
55 |
scratch.add(" I.next();"); |
1eee624cddb3
8007297: [pack200] allow opcodes with InterfaceMethodRefs
ksrini
parents:
15526
diff
changeset
|
56 |
scratch.add(" }"); |
15526
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
57 |
scratch.add("}"); |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
58 |
File cwd = new File("."); |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
59 |
File javaFile = new File(cwd, javaFileName); |
17490
46864558d068
8001163: [pack200] should support attributes introduced by JSR-308
ksrini
parents:
16050
diff
changeset
|
60 |
Utils.createFile(javaFile, scratch); |
15526
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
61 |
|
16050
1eee624cddb3
8007297: [pack200] allow opcodes with InterfaceMethodRefs
ksrini
parents:
15526
diff
changeset
|
62 |
// -g to compare LVT and LNT entries |
15526
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
63 |
Utils.compiler("-g", javaFile.getName()); |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
64 |
|
16050
1eee624cddb3
8007297: [pack200] allow opcodes with InterfaceMethodRefs
ksrini
parents:
15526
diff
changeset
|
65 |
File propsFile = new File("pack.props"); |
1eee624cddb3
8007297: [pack200] allow opcodes with InterfaceMethodRefs
ksrini
parents:
15526
diff
changeset
|
66 |
scratch.clear(); |
1eee624cddb3
8007297: [pack200] allow opcodes with InterfaceMethodRefs
ksrini
parents:
15526
diff
changeset
|
67 |
scratch.add("com.sun.java.util.jar.pack.class.format.error=error"); |
1eee624cddb3
8007297: [pack200] allow opcodes with InterfaceMethodRefs
ksrini
parents:
15526
diff
changeset
|
68 |
scratch.add("pack.unknown.attribute=error"); |
17490
46864558d068
8001163: [pack200] should support attributes introduced by JSR-308
ksrini
parents:
16050
diff
changeset
|
69 |
Utils.createFile(propsFile, scratch); |
15526
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
70 |
// jar the file up |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
71 |
File testjarFile = new File(cwd, "test" + Utils.JAR_FILE_EXT); |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
72 |
Utils.jar("cvf", testjarFile.getName(), "."); |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
73 |
|
16050
1eee624cddb3
8007297: [pack200] allow opcodes with InterfaceMethodRefs
ksrini
parents:
15526
diff
changeset
|
74 |
Utils.testWithRepack(testjarFile, "--config-file=" + propsFile.getName()); |
15526
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
75 |
} |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
diff
changeset
|
76 |
} |