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