author | iignatyev |
Tue, 29 Nov 2016 00:25:13 +0300 | |
changeset 42607 | acd91f1875d4 |
parent 41325 | 050786119cb7 |
child 43972 | 1ade39b8381b |
permissions | -rw-r--r-- |
33160 | 1 |
/* |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40362
diff
changeset
|
2 |
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
33160 | 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 |
|
42607
acd91f1875d4
8170227: use vm.jvmci property in compiler/jvmci tests
iignatyev
parents:
41325
diff
changeset
|
27 |
* @requires vm.jvmci |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40362
diff
changeset
|
28 |
* @library / /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 |
38 |
* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI |
|
39 |
* compiler.jvmci.compilerToVM.FindUniqueConcreteMethodTest |
|
33160 | 40 |
*/ |
41 |
||
42 |
package compiler.jvmci.compilerToVM; |
|
43 |
||
40059 | 44 |
import compiler.jvmci.common.CTVMUtilities; |
40362
94addd7cfa10
8162477: [JVMCI] assert(wf.check_method_context(ctxk, m)) failed: proper context
never
parents:
40059
diff
changeset
|
45 |
import compiler.jvmci.common.testcases.DuplicateSimpleSingleImplementerInterface; |
94addd7cfa10
8162477: [JVMCI] assert(wf.check_method_context(ctxk, m)) failed: proper context
never
parents:
40059
diff
changeset
|
46 |
import compiler.jvmci.common.testcases.SimpleSingleImplementerInterface; |
33160 | 47 |
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
|
48 |
import compiler.jvmci.common.testcases.MultipleSuperImplementers; |
33160 | 49 |
import compiler.jvmci.common.testcases.SingleImplementer; |
40059 | 50 |
import compiler.jvmci.common.testcases.SingleImplementerInterface; |
33160 | 51 |
import compiler.jvmci.common.testcases.SingleSubclass; |
40059 | 52 |
import jdk.test.lib.Asserts; |
53 |
import jdk.test.lib.Utils; |
|
54 |
import jdk.vm.ci.hotspot.CompilerToVMHelper; |
|
55 |
import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; |
|
56 |
import jdk.vm.ci.hotspot.HotSpotResolvedObjectType; |
|
57 |
||
33160 | 58 |
import java.lang.reflect.Method; |
59 |
import java.util.HashSet; |
|
60 |
import java.util.Set; |
|
61 |
||
62 |
public class FindUniqueConcreteMethodTest { |
|
63 |
public static void main(String args[]) { |
|
64 |
FindUniqueConcreteMethodTest test = new FindUniqueConcreteMethodTest(); |
|
65 |
try { |
|
66 |
for (TestCase tcase : createTestCases()) { |
|
67 |
test.runTest(tcase); |
|
68 |
} |
|
69 |
} catch (NoSuchMethodException e) { |
|
70 |
throw new Error("TEST BUG: can't find method", e); |
|
71 |
} |
|
72 |
} |
|
73 |
||
74 |
private static Set<TestCase> createTestCases() { |
|
75 |
Set<TestCase> result = new HashSet<>(); |
|
76 |
// a public method |
|
41325 | 77 |
result.add(new TestCase(true, SingleSubclass.class, "usualMethod")); |
33160 | 78 |
// overriden method |
41325 | 79 |
result.add(new TestCase(true, SingleSubclass.class, "overridenMethod")); |
33160 | 80 |
// private method |
41325 | 81 |
result.add(new TestCase(true, SingleSubclass.class, "privateMethod")); |
33160 | 82 |
// protected method |
41325 | 83 |
result.add(new TestCase(true, SingleSubclass.class, "protectedMethod")); |
33160 | 84 |
// default(package-private) method |
41325 | 85 |
result.add(new TestCase(true, SingleSubclass.class, "defaultAccessMethod")); |
33160 | 86 |
// default interface method redefined in implementer |
41325 | 87 |
result.add(new TestCase(true, MultipleImplementer1.class, "defaultMethod")); |
33160 | 88 |
// interface method |
41325 | 89 |
result.add(new TestCase(true, MultipleImplementer1.class, "testMethod")); |
33160 | 90 |
// default interface method not redefined in implementer |
41325 | 91 |
// result.add(new TestCase(true, SingleImplementer.class, |
92 |
// SingleImplementerInterface.class, "defaultMethod")); |
|
33160 | 93 |
// static method |
41325 | 94 |
result.add(new TestCase(false, SingleSubclass.class, "staticMethod")); |
40362
94addd7cfa10
8162477: [JVMCI] assert(wf.check_method_context(ctxk, m)) failed: proper context
never
parents:
40059
diff
changeset
|
95 |
// interface method |
94addd7cfa10
8162477: [JVMCI] assert(wf.check_method_context(ctxk, m)) failed: proper context
never
parents:
40059
diff
changeset
|
96 |
result.add(new TestCase(false, MultipleSuperImplementers.class, |
41325 | 97 |
DuplicateSimpleSingleImplementerInterface.class, "interfaceMethod")); |
40362
94addd7cfa10
8162477: [JVMCI] assert(wf.check_method_context(ctxk, m)) failed: proper context
never
parents:
40059
diff
changeset
|
98 |
result.add(new TestCase(false, MultipleSuperImplementers.class, |
41325 | 99 |
SimpleSingleImplementerInterface.class, "interfaceMethod")); |
33160 | 100 |
return result; |
101 |
} |
|
102 |
||
103 |
private void runTest(TestCase tcase) throws NoSuchMethodException { |
|
104 |
System.out.println(tcase); |
|
105 |
Method method = tcase.holder.getDeclaredMethod(tcase.methodName); |
|
41325 | 106 |
HotSpotResolvedJavaMethod testMethod = CTVMUtilities.getResolvedMethod(method); |
107 |
||
33632 | 108 |
HotSpotResolvedObjectType resolvedType = CompilerToVMHelper |
109 |
.lookupType(Utils.toJVMTypeSignature(tcase.receiver), getClass(), |
|
33160 | 110 |
/* resolve = */ true); |
33632 | 111 |
HotSpotResolvedJavaMethod concreteMethod = CompilerToVMHelper |
33160 | 112 |
.findUniqueConcreteMethod(resolvedType, testMethod); |
113 |
Asserts.assertEQ(concreteMethod, tcase.isPositive ? testMethod : null, |
|
114 |
"Unexpected concrete method for " + tcase.methodName); |
|
115 |
} |
|
116 |
||
117 |
private static class TestCase { |
|
33632 | 118 |
public final Class<?> receiver; |
33160 | 119 |
public final Class<?> holder; |
120 |
public final String methodName; |
|
121 |
public final boolean isPositive; |
|
122 |
||
123 |
public TestCase(boolean isPositive, Class<?> clazz, Class<?> holder, |
|
41325 | 124 |
String methodName) { |
33632 | 125 |
this.receiver = clazz; |
33160 | 126 |
this.methodName = methodName; |
127 |
this.isPositive = isPositive; |
|
128 |
this.holder = holder; |
|
40362
94addd7cfa10
8162477: [JVMCI] assert(wf.check_method_context(ctxk, m)) failed: proper context
never
parents:
40059
diff
changeset
|
129 |
} |
94addd7cfa10
8162477: [JVMCI] assert(wf.check_method_context(ctxk, m)) failed: proper context
never
parents:
40059
diff
changeset
|
130 |
|
41325 | 131 |
public TestCase(boolean isPositive, Class<?> clazz, String methodName) { |
132 |
this(isPositive, clazz, clazz, methodName); |
|
33160 | 133 |
} |
134 |
||
135 |
@Override |
|
136 |
public String toString() { |
|
41325 | 137 |
return String.format("CASE: receiver=%s, holder=%s, method=%s, isPositive=%s", |
138 |
receiver.getName(), holder.getName(), methodName, isPositive); |
|
33160 | 139 |
} |
140 |
} |
|
141 |
} |