Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/jdk17u
Path: blob/master/test/hotspot/jtreg/runtime/InvocationTests/invocationOldCHATests.java
64474 views
1
/*
2
* Copyright (c) 2019, 2021, 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
/*
26
* @test id=special
27
* @summary Run invocation tests with old CHA (-XX:-UseVtableBasedCHA)
28
* @library /test/lib
29
* @modules java.base/jdk.internal.org.objectweb.asm
30
* java.base/jdk.internal.misc
31
* @compile invokespecial/Checker.java invokespecial/ClassGenerator.java invokespecial/Generator.java
32
*
33
* @run driver/timeout=1800 invocationOldCHATests special
34
*/
35
36
/*
37
* @test id=virtual
38
* @summary Run invocation tests with old CHA (-XX:-UseVtableBasedCHA)
39
* @requires vm.flagless
40
* @library /test/lib
41
* @modules java.base/jdk.internal.org.objectweb.asm
42
* java.base/jdk.internal.misc
43
* @compile invokevirtual/Checker.java invokevirtual/ClassGenerator.java invokevirtual/Generator.java
44
*
45
* @run driver/timeout=1800 invocationOldCHATests virtual
46
*/
47
48
/*
49
* @test id=interface
50
* @summary Run invocation tests with old CHA (-XX:-UseVtableBasedCHA)
51
* @requires vm.flagless
52
* @library /test/lib
53
* @modules java.base/jdk.internal.org.objectweb.asm
54
* java.base/jdk.internal.misc
55
* @compile invokeinterface/Checker.java invokeinterface/ClassGenerator.java invokeinterface/Generator.java
56
*
57
* @run driver/timeout=1800 invocationOldCHATests interface
58
*/
59
60
import jdk.test.lib.process.ProcessTools;
61
import jdk.test.lib.process.OutputAnalyzer;
62
import jdk.test.lib.compiler.InMemoryJavaCompiler;
63
64
public class invocationOldCHATests {
65
66
public static void runTest(String whichTests, String classFileVersion) throws Throwable {
67
System.out.println("\nOld CHA invocation tests, Tests: " + whichTests +
68
", class file version: " + classFileVersion);
69
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xmx128M",
70
"-Xcomp", "-XX:+UnlockDiagnosticVMOptions", "-XX:-UseVtableBasedCHA",
71
"--add-exports", "java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED",
72
whichTests, "--classfile_version=" + classFileVersion);
73
OutputAnalyzer output = new OutputAnalyzer(pb.start());
74
try {
75
output.shouldContain("EXECUTION STATUS: PASSED");
76
output.shouldHaveExitValue(0);
77
} catch (Throwable e) {
78
System.out.println(
79
"\nNote that an entry such as 'B.m/C.m' in the failure chart means that" +
80
" the test case failed because method B.m was invoked but the test " +
81
"expected method C.m to be invoked. Similarly, a result such as 'AME/C.m'" +
82
" means that an AbstractMethodError exception was thrown but the test" +
83
" case expected method C.m to be invoked.");
84
System.out.println(
85
"\nAlso note that passing --dump to invoke*.Generator will" +
86
" dump the generated classes (for debugging purposes).\n");
87
88
throw e;
89
}
90
}
91
92
public static void main(String args[]) throws Throwable {
93
if (args.length < 1) {
94
throw new IllegalArgumentException("Should provide the test name");
95
}
96
String testName = args[0];
97
98
// Get current major class file version and test with it.
99
byte klassbuf[] = InMemoryJavaCompiler.compile("blah", "public class blah { }");
100
int major_version = klassbuf[6] << 8 | klassbuf[7];
101
102
switch (testName) {
103
case "special":
104
runTest("invokespecial.Generator", String.valueOf(major_version));
105
break;
106
case "virtual":
107
runTest("invokevirtual.Generator", String.valueOf(major_version));
108
break;
109
case "interface":
110
runTest("invokeinterface.Generator", String.valueOf(major_version));
111
break;
112
default:
113
throw new IllegalArgumentException("Unknown test name: " + testName);
114
}
115
}
116
}
117
118