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