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