Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/oracle/GetMethodOptionTest.java
41152 views
1
/*
2
* Copyright (c) 2015, 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
* @test
26
* @bug 8074980
27
* @library /test/lib
28
* @modules java.base/jdk.internal.misc
29
* @build sun.hotspot.WhiteBox
30
* @requires vm.debug == true
31
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
32
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
33
* -XX:CompileCommand=option,compiler.oracle.GetMethodOptionTest::test,ccstrlist,TestOptionList,_foo,_bar
34
* -XX:CompileCommand=option,compiler.oracle.GetMethodOptionTest::test,ccstr,TestOptionStr,_foo
35
* -XX:CompileCommand=option,compiler.oracle.GetMethodOptionTest::test,bool,TestOptionBool,false
36
* -XX:CompileCommand=option,compiler.oracle.GetMethodOptionTest::test,intx,TestOptionInt,-1
37
* -XX:CompileCommand=option,compiler.oracle.GetMethodOptionTest::test,uintx,TestOptionUint,1
38
* -XX:CompileCommand=option,compiler.oracle.GetMethodOptionTest::test,TestOptionBool2
39
* -XX:CompileCommand=option,compiler.oracle.GetMethodOptionTest::test,double,TestOptionDouble,1.123
40
* compiler.oracle.GetMethodOptionTest
41
*
42
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
43
* -XX:CompileCommand=option,compiler.oracle.GetMethodOptionTest::test,bool,TestOptionBool,false,intx,TestOptionInt,-1,uintx,TestOptionUint,1,bool,TestOptionBool2,true,ccstr,TestOptionStr,_foo,double,TestOptionDouble,1.123,ccstrlist,TestOptionList,_foo,_bar
44
* compiler.oracle.GetMethodOptionTest
45
*
46
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
47
* -XX:CompileCommand=TestOptionList,compiler.oracle.GetMethodOptionTest::test,_foo,_bar
48
* -XX:CompileCommand=TestOptionStr,compiler.oracle.GetMethodOptionTest::test,_foo
49
* -XX:CompileCommand=TestOptionBool,compiler.oracle.GetMethodOptionTest::test,false
50
-XX:CompileCommand=TestOptionBool2,compiler.oracle.GetMethodOptionTest::test
51
* -XX:CompileCommand=TestOptionInt,compiler.oracle.GetMethodOptionTest::test,-1
52
* -XX:CompileCommand=TestOptionUint,compiler.oracle.GetMethodOptionTest::test,1
53
* -XX:CompileCommand=TestOptionDouble,compiler.oracle.GetMethodOptionTest::test,1.123
54
* compiler.oracle.GetMethodOptionTest
55
*/
56
57
package compiler.oracle;
58
59
import jdk.test.lib.Asserts;
60
import sun.hotspot.WhiteBox;
61
62
import java.lang.reflect.Executable;
63
import java.util.function.BiFunction;
64
65
public class GetMethodOptionTest {
66
private static final WhiteBox WB = WhiteBox.getWhiteBox();
67
public static void main(String[] args) {
68
Executable test = getMethod("test");
69
Executable test2 = getMethod("test2");
70
BiFunction<Executable, String, Object> getter = WB::getMethodOption;
71
for (TestCase testCase : TestCase.values()) {
72
Object expected = testCase.value;
73
String name = testCase.name();
74
Asserts.assertEQ(expected, getter.apply(test, name),
75
testCase + ": universal getter returns wrong value");
76
Asserts.assertEQ(expected, testCase.getter.apply(test, name),
77
testCase + ": specific getter returns wrong value");
78
Asserts.assertEQ(null, getter.apply(test2, name),
79
testCase + ": universal getter returns value for unused method");
80
Asserts.assertEQ(null, testCase.getter.apply(test2, name),
81
testCase + ": type specific getter returns value for unused method");
82
}
83
}
84
private static void test() { }
85
private static void test2() { }
86
87
private static enum TestCase {
88
TestOptionBool(false, WB::getMethodBooleanOption),
89
TestOptionStr("_foo", WB::getMethodStringOption),
90
TestOptionInt(-1L, WB::getMethodIntxOption),
91
TestOptionUint(1L, WB::getMethodUintxOption),
92
TestOptionBool2(true, WB::getMethodBooleanOption),
93
TestOptionDouble(1.123d, WB::getMethodDoubleOption),
94
TestOptionList("_foo _bar", WB::getMethodStringOption);
95
96
public final Object value;
97
public final BiFunction<Executable, String, Object> getter;
98
private TestCase(Object value, BiFunction<Executable, String, Object> getter) {
99
this.value = value;
100
this.getter = getter;
101
}
102
}
103
104
private static Executable getMethod(String name) {
105
Executable result;
106
try {
107
result = GetMethodOptionTest.class.getDeclaredMethod(name);
108
} catch (NoSuchMethodException | SecurityException e) {
109
throw new Error("TESTBUG : can't get method " + name, e);
110
}
111
return result;
112
}
113
}
114
115