Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/jvmci/compilerToVM/AsResolvedJavaMethodTest.java
41153 views
1
/*
2
* Copyright (c) 2015, 2019, 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 8136421
27
* @requires vm.jvmci
28
* @library /test/lib /
29
* @library ../common/patches
30
* @modules java.base/jdk.internal.misc
31
* @modules java.base/jdk.internal.org.objectweb.asm
32
* java.base/jdk.internal.org.objectweb.asm.tree
33
* jdk.internal.vm.ci/jdk.vm.ci.hotspot
34
* jdk.internal.vm.ci/jdk.vm.ci.code
35
* jdk.internal.vm.ci/jdk.vm.ci.meta
36
* jdk.internal.vm.ci/jdk.vm.ci.runtime
37
*
38
* @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
39
* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler
40
* compiler.jvmci.compilerToVM.AsResolvedJavaMethodTest
41
*/
42
43
package compiler.jvmci.compilerToVM;
44
45
import jdk.test.lib.Asserts;
46
import jdk.vm.ci.hotspot.CompilerToVMHelper;
47
import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
48
49
import java.lang.reflect.Executable;
50
import java.util.Arrays;
51
import java.util.ArrayList;
52
import java.util.List;
53
54
public class AsResolvedJavaMethodTest {
55
56
private static class A {
57
{
58
System.out.println("Dummy");
59
}
60
public void f1() {}
61
public int f2() { return 0; }
62
public String f3() { return ""; }
63
}
64
65
66
private static class S {
67
static {
68
System.out.println("Dummy static");
69
}
70
public S() {}
71
public void f1() {}
72
public int f2() { return 0; }
73
public String f3() { return ""; }
74
}
75
76
private class B extends A {
77
public void f4() {}
78
}
79
80
private interface I {
81
void f1();
82
int f2();
83
String f3();
84
}
85
86
public static void main(String[] args) {
87
List<Class<?>> testCases = getTestCases();
88
testCases.forEach(AsResolvedJavaMethodTest::test);
89
}
90
91
private static List<Class<?>> getTestCases() {
92
List<Class<?>> testCases = new ArrayList<>();
93
testCases.add(A.class);
94
testCases.add(S.class);
95
testCases.add(I.class);
96
testCases.add(B.class);
97
return testCases;
98
}
99
100
private static void test(Class<?> aClass) {
101
testCorrectMethods(aClass);
102
}
103
104
private static void testCorrectMethods(Class<?> holder) {
105
List<Executable> executables = new ArrayList<>();
106
executables.addAll(Arrays.asList(holder.getDeclaredMethods()));
107
executables.addAll(Arrays.asList(holder.getDeclaredConstructors()));
108
for (Executable executable : executables) {
109
HotSpotResolvedJavaMethod method = CompilerToVMHelper
110
.asResolvedJavaMethod(executable);
111
Asserts.assertNotNull(method, "could not convert " + method);
112
}
113
}
114
}
115
116