author | never |
Tue, 02 Aug 2016 17:12:16 -0700 | |
changeset 40362 | 94addd7cfa10 |
parent 40059 | c2304140ed64 |
child 40631 | ed82623d7831 |
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 |
* @test |
|
26 |
* @bug 8136421 |
|
39291
a4efe145313d
8157831: JVMCI tests should not be executed on linux-arm32
lmesnik
parents:
38152
diff
changeset
|
27 |
* @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") |
33730
30e064828045
8140189: [TESTBUG] Get rid of "@library /../../test/lib" in jtreg tests
cjplummer
parents:
33160
diff
changeset
|
28 |
* @library / /testlibrary /test/lib |
36508 | 29 |
* @library ../common/patches |
38152
80e5da81fb2c
8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents:
36508
diff
changeset
|
30 |
* @modules java.base/jdk.internal.misc |
36508 | 31 |
* @modules java.base/jdk.internal.org.objectweb.asm |
32 |
* java.base/jdk.internal.org.objectweb.asm.tree |
|
33 |
* jdk.vm.ci/jdk.vm.ci.hotspot |
|
34 |
* jdk.vm.ci/jdk.vm.ci.code |
|
40362
94addd7cfa10
8162477: [JVMCI] assert(wf.check_method_context(ctxk, m)) failed: proper context
never
parents:
40059
diff
changeset
|
35 |
* jdk.vm.ci/jdk.vm.ci.meta |
94addd7cfa10
8162477: [JVMCI] assert(wf.check_method_context(ctxk, m)) failed: proper context
never
parents:
40059
diff
changeset
|
36 |
* jdk.vm.ci/jdk.vm.ci.runtime |
36508 | 37 |
* @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper |
33160 | 38 |
* @build compiler.jvmci.compilerToVM.FindUniqueConcreteMethodTest |
36508 | 39 |
* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI |
40 |
* compiler.jvmci.compilerToVM.FindUniqueConcreteMethodTest |
|
33160 | 41 |
*/ |
42 |
||
43 |
package compiler.jvmci.compilerToVM; |
|
44 |
||
40059 | 45 |
import compiler.jvmci.common.CTVMUtilities; |
40362
94addd7cfa10
8162477: [JVMCI] assert(wf.check_method_context(ctxk, m)) failed: proper context
never
parents:
40059
diff
changeset
|
46 |
import compiler.jvmci.common.testcases.DuplicateSimpleSingleImplementerInterface; |
94addd7cfa10
8162477: [JVMCI] assert(wf.check_method_context(ctxk, m)) failed: proper context
never
parents:
40059
diff
changeset
|
47 |
import compiler.jvmci.common.testcases.SimpleSingleImplementerInterface; |
33160 | 48 |
import compiler.jvmci.common.testcases.MultipleImplementer1; |
40362
94addd7cfa10
8162477: [JVMCI] assert(wf.check_method_context(ctxk, m)) failed: proper context
never
parents:
40059
diff
changeset
|
49 |
import compiler.jvmci.common.testcases.MultipleSuperImplementers; |
33160 | 50 |
import compiler.jvmci.common.testcases.SingleImplementer; |
40059 | 51 |
import compiler.jvmci.common.testcases.SingleImplementerInterface; |
33160 | 52 |
import compiler.jvmci.common.testcases.SingleSubclass; |
40059 | 53 |
import jdk.test.lib.Asserts; |
54 |
import jdk.test.lib.Utils; |
|
55 |
import jdk.vm.ci.hotspot.CompilerToVMHelper; |
|
56 |
import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; |
|
57 |
import jdk.vm.ci.hotspot.HotSpotResolvedObjectType; |
|
58 |
||
33160 | 59 |
import java.lang.reflect.Method; |
60 |
import java.util.HashSet; |
|
61 |
import java.util.Set; |
|
62 |
||
63 |
public class FindUniqueConcreteMethodTest { |
|
64 |
public static void main(String args[]) { |
|
65 |
FindUniqueConcreteMethodTest test = new FindUniqueConcreteMethodTest(); |
|
66 |
try { |
|
67 |
for (TestCase tcase : createTestCases()) { |
|
68 |
test.runTest(tcase); |
|
69 |
} |
|
70 |
} catch (NoSuchMethodException e) { |
|
71 |
throw new Error("TEST BUG: can't find method", e); |
|
72 |
} |
|
73 |
} |
|
74 |
||
75 |
private static Set<TestCase> createTestCases() { |
|
76 |
Set<TestCase> result = new HashSet<>(); |
|
77 |
// a public method |
|
78 |
result.add(new TestCase(true, SingleSubclass.class, |
|
79 |
SingleSubclass.class, "usualMethod")); |
|
80 |
// overriden method |
|
81 |
result.add(new TestCase(true, SingleSubclass.class, |
|
82 |
SingleSubclass.class, "overridenMethod")); |
|
83 |
// private method |
|
84 |
result.add(new TestCase(true, SingleSubclass.class, |
|
85 |
SingleSubclass.class, "privateMethod")); |
|
86 |
// protected method |
|
87 |
result.add(new TestCase(true, SingleSubclass.class, |
|
88 |
SingleSubclass.class, "protectedMethod")); |
|
89 |
// default(package-private) method |
|
90 |
result.add(new TestCase(true, SingleSubclass.class, |
|
91 |
SingleSubclass.class, "defaultAccessMethod")); |
|
92 |
// default interface method redefined in implementer |
|
93 |
result.add(new TestCase(true, MultipleImplementer1.class, |
|
94 |
MultipleImplementer1.class, "defaultMethod")); |
|
95 |
// interface method |
|
96 |
result.add(new TestCase(true, MultipleImplementer1.class, |
|
97 |
MultipleImplementer1.class, "testMethod")); |
|
98 |
// default interface method not redefined in implementer |
|
99 |
result.add(new TestCase(true, SingleImplementer.class, |
|
100 |
SingleImplementerInterface.class, "defaultMethod")); |
|
101 |
// static method |
|
102 |
result.add(new TestCase(false, SingleSubclass.class, |
|
103 |
SingleSubclass.class, "staticMethod")); |
|
40362
94addd7cfa10
8162477: [JVMCI] assert(wf.check_method_context(ctxk, m)) failed: proper context
never
parents:
40059
diff
changeset
|
104 |
// interface method |
94addd7cfa10
8162477: [JVMCI] assert(wf.check_method_context(ctxk, m)) failed: proper context
never
parents:
40059
diff
changeset
|
105 |
result.add(new TestCase(false, MultipleSuperImplementers.class, |
94addd7cfa10
8162477: [JVMCI] assert(wf.check_method_context(ctxk, m)) failed: proper context
never
parents:
40059
diff
changeset
|
106 |
DuplicateSimpleSingleImplementerInterface.class, "interfaceMethod", false)); |
94addd7cfa10
8162477: [JVMCI] assert(wf.check_method_context(ctxk, m)) failed: proper context
never
parents:
40059
diff
changeset
|
107 |
result.add(new TestCase(false, MultipleSuperImplementers.class, |
94addd7cfa10
8162477: [JVMCI] assert(wf.check_method_context(ctxk, m)) failed: proper context
never
parents:
40059
diff
changeset
|
108 |
SimpleSingleImplementerInterface.class, "interfaceMethod", false)); |
33160 | 109 |
return result; |
110 |
} |
|
111 |
||
112 |
private void runTest(TestCase tcase) throws NoSuchMethodException { |
|
113 |
System.out.println(tcase); |
|
114 |
Method method = tcase.holder.getDeclaredMethod(tcase.methodName); |
|
33632 | 115 |
HotSpotResolvedJavaMethod testMethod = CTVMUtilities |
40362
94addd7cfa10
8162477: [JVMCI] assert(wf.check_method_context(ctxk, m)) failed: proper context
never
parents:
40059
diff
changeset
|
116 |
.getResolvedMethod(tcase.methodFromReceiver ? tcase.receiver : tcase.holder, method); |
33632 | 117 |
HotSpotResolvedObjectType resolvedType = CompilerToVMHelper |
118 |
.lookupType(Utils.toJVMTypeSignature(tcase.receiver), getClass(), |
|
33160 | 119 |
/* resolve = */ true); |
33632 | 120 |
HotSpotResolvedJavaMethod concreteMethod = CompilerToVMHelper |
33160 | 121 |
.findUniqueConcreteMethod(resolvedType, testMethod); |
122 |
Asserts.assertEQ(concreteMethod, tcase.isPositive ? testMethod : null, |
|
123 |
"Unexpected concrete method for " + tcase.methodName); |
|
124 |
} |
|
125 |
||
126 |
private static class TestCase { |
|
33632 | 127 |
public final Class<?> receiver; |
33160 | 128 |
public final Class<?> holder; |
129 |
public final String methodName; |
|
130 |
public final boolean isPositive; |
|
40362
94addd7cfa10
8162477: [JVMCI] assert(wf.check_method_context(ctxk, m)) failed: proper context
never
parents:
40059
diff
changeset
|
131 |
public final boolean methodFromReceiver; |
33160 | 132 |
|
133 |
public TestCase(boolean isPositive, Class<?> clazz, Class<?> holder, |
|
40362
94addd7cfa10
8162477: [JVMCI] assert(wf.check_method_context(ctxk, m)) failed: proper context
never
parents:
40059
diff
changeset
|
134 |
String methodName, boolean methodFromReceiver) { |
33632 | 135 |
this.receiver = clazz; |
33160 | 136 |
this.methodName = methodName; |
137 |
this.isPositive = isPositive; |
|
138 |
this.holder = holder; |
|
40362
94addd7cfa10
8162477: [JVMCI] assert(wf.check_method_context(ctxk, m)) failed: proper context
never
parents:
40059
diff
changeset
|
139 |
this.methodFromReceiver = methodFromReceiver; |
94addd7cfa10
8162477: [JVMCI] assert(wf.check_method_context(ctxk, m)) failed: proper context
never
parents:
40059
diff
changeset
|
140 |
} |
94addd7cfa10
8162477: [JVMCI] assert(wf.check_method_context(ctxk, m)) failed: proper context
never
parents:
40059
diff
changeset
|
141 |
|
94addd7cfa10
8162477: [JVMCI] assert(wf.check_method_context(ctxk, m)) failed: proper context
never
parents:
40059
diff
changeset
|
142 |
public TestCase(boolean isPositive, Class<?> clazz, Class<?> holder, String methodName) { |
94addd7cfa10
8162477: [JVMCI] assert(wf.check_method_context(ctxk, m)) failed: proper context
never
parents:
40059
diff
changeset
|
143 |
this(isPositive, clazz, holder, methodName, true); |
33160 | 144 |
} |
145 |
||
146 |
@Override |
|
147 |
public String toString() { |
|
40362
94addd7cfa10
8162477: [JVMCI] assert(wf.check_method_context(ctxk, m)) failed: proper context
never
parents:
40059
diff
changeset
|
148 |
return String.format("CASE: receiver=%s, holder=%s, method=%s, isPositive=%s, methodFromReceiver=%s", |
94addd7cfa10
8162477: [JVMCI] assert(wf.check_method_context(ctxk, m)) failed: proper context
never
parents:
40059
diff
changeset
|
149 |
receiver.getName(), holder.getName(), methodName, isPositive, methodFromReceiver); |
33160 | 150 |
} |
151 |
} |
|
152 |
} |