Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/tools/pack200/InstructionTests.java
38833 views
1
/*
2
* Copyright (c) 2013, 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
import java.io.File;
24
import java.util.ArrayList;
25
import java.util.List;
26
27
/*
28
* @test
29
* @bug 8003549 8007297
30
* @summary tests class files instruction formats introduced in JSR-335
31
* @compile -XDignore.symbol.file Utils.java InstructionTests.java
32
* @run main InstructionTests
33
* @author ksrini
34
*/
35
public class InstructionTests {
36
public static void main(String... args) throws Exception {
37
testInvokeOpCodes();
38
Utils.cleanup();
39
}
40
/*
41
* the following should produce invokestatic and invokespecial
42
* on InterfaceMethodRefs vs. MethodRefs, packer/unpacker should work
43
*/
44
static void testInvokeOpCodes() throws Exception {
45
List<String> scratch = new ArrayList<>();
46
final String fname = "A";
47
String javaFileName = fname + Utils.JAVA_FILE_EXT;
48
scratch.add("interface I {");
49
scratch.add(" default void forEach(){}");
50
scratch.add(" static void next() {}");
51
scratch.add("}");
52
scratch.add("class A implements I {");
53
scratch.add(" public void forEach(Object o){");
54
scratch.add(" I.super.forEach();");
55
scratch.add(" I.next();");
56
scratch.add(" }");
57
scratch.add("}");
58
File cwd = new File(".");
59
File javaFile = new File(cwd, javaFileName);
60
Utils.createFile(javaFile, scratch);
61
62
// -g to compare LVT and LNT entries
63
Utils.compiler("-g", javaFile.getName());
64
65
File propsFile = new File("pack.props");
66
scratch.clear();
67
scratch.add("com.sun.java.util.jar.pack.class.format.error=error");
68
scratch.add("pack.unknown.attribute=error");
69
Utils.createFile(propsFile, scratch);
70
// jar the file up
71
File testjarFile = new File(cwd, "test" + Utils.JAR_FILE_EXT);
72
Utils.jar("cvf", testjarFile.getName(), ".");
73
74
Utils.testWithRepack(testjarFile, "--config-file=" + propsFile.getName());
75
}
76
}
77
78