author | cjplummer |
Thu, 29 Oct 2015 12:04:04 -0700 | |
changeset 33730 | 30e064828045 |
parent 33160 | c59f1676d27e |
child 33813 | 4f376e851453 |
permissions | -rw-r--r-- |
33160 | 1 |
/* |
2 |
* Copyright (c) 2015, 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 (os.simpleArch == "x64" | os.simpleArch == "sparcv9") & os.arch != "aarch64" |
|
33730
30e064828045
8140189: [TESTBUG] Get rid of "@library /../../test/lib" in jtreg tests
cjplummer
parents:
33160
diff
changeset
|
29 |
* @library /testlibrary /test/lib / |
33160 | 30 |
* @compile ../common/CompilerToVMHelper.java |
31 |
* @run main ClassFileInstaller jdk.vm.ci.hotspot.CompilerToVMHelper |
|
32 |
* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI |
|
33 |
* -Xbootclasspath/a:. |
|
34 |
* compiler.jvmci.compilerToVM.GetResolvedJavaMethodAtSlotTest |
|
35 |
*/ |
|
36 |
||
37 |
package compiler.jvmci.compilerToVM; |
|
38 |
||
39 |
import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethodImpl; |
|
40 |
import jdk.vm.ci.hotspot.CompilerToVMHelper; |
|
41 |
import jdk.test.lib.Asserts; |
|
42 |
import java.util.HashMap; |
|
43 |
import java.util.Map; |
|
44 |
||
45 |
public class GetResolvedJavaMethodAtSlotTest { |
|
46 |
||
47 |
private static class A { |
|
48 |
{ |
|
49 |
System.out.println("Dummy"); |
|
50 |
} |
|
51 |
public void f1() {} |
|
52 |
public int f2() { return 0; } |
|
53 |
public String f3() { return ""; } |
|
54 |
} |
|
55 |
||
56 |
||
57 |
private static class S { |
|
58 |
static { |
|
59 |
System.out.println("Dummy static"); |
|
60 |
} |
|
61 |
public S() {} |
|
62 |
public void f1() {} |
|
63 |
public int f2() { return 0; } |
|
64 |
public String f3() { return ""; } |
|
65 |
} |
|
66 |
||
67 |
private class B extends A { |
|
68 |
public void f4() {} |
|
69 |
} |
|
70 |
||
71 |
private interface I { |
|
72 |
void f1(); |
|
73 |
int f2(); |
|
74 |
String f3(); |
|
75 |
} |
|
76 |
||
77 |
public static void main(String[] args) { |
|
78 |
Map<Class<?>, Integer> testCases = getTestCases(); |
|
79 |
testCases.forEach(GetResolvedJavaMethodAtSlotTest::test); |
|
80 |
} |
|
81 |
||
82 |
private static Map<Class<?>, Integer> getTestCases() { |
|
83 |
Map<Class<?>, Integer> testCases = new HashMap<>(); |
|
84 |
testCases.put(A.class, 5); // ctor, init, f1, f2, f3 |
|
85 |
testCases.put(S.class, 5); // ctor, cinit, f1, f2, f3 |
|
86 |
testCases.put(I.class, 3); // f1, f2, f3 |
|
87 |
testCases.put(B.class, 2); // ctor, f4 |
|
88 |
return testCases; |
|
89 |
} |
|
90 |
||
91 |
private static void test(Class<?> aClass, int methodNumber) { |
|
92 |
testSlotBigger(aClass); |
|
93 |
testCorrectMethods(aClass, methodNumber); |
|
94 |
} |
|
95 |
||
96 |
private static void testSlotBigger(Class<?> holder) { |
|
97 |
HotSpotResolvedJavaMethodImpl method |
|
98 |
= CompilerToVMHelper.getResolvedJavaMethodAtSlot(holder, 50); |
|
99 |
Asserts.assertNull(method, "Got method for non existing slot 50 in " |
|
100 |
+ holder); |
|
101 |
} |
|
102 |
||
103 |
private static void testCorrectMethods(Class<?> holder, int methodsNumber) { |
|
104 |
for (int i = 0; i < methodsNumber; i++) { |
|
105 |
HotSpotResolvedJavaMethodImpl method = CompilerToVMHelper |
|
106 |
.getResolvedJavaMethodAtSlot(holder, i); |
|
107 |
Asserts.assertNotNull(method, "Did not got method for slot " + i |
|
108 |
+ " in class " + holder.getCanonicalName()); |
|
109 |
} |
|
110 |
} |
|
111 |
} |