author | chegar |
Thu, 17 Oct 2019 20:54:25 +0100 | |
branch | datagramsocketimpl-branch |
changeset 58679 | 9c3209ff7550 |
parent 58678 | 9cf78a70fa4f |
parent 55298 | 1fe17d2be502 |
permissions | -rw-r--r-- |
33160 | 1 |
/* |
55206 | 2 |
* Copyright (c) 2015, 2019, 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 |
|
43972 | 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 |
* @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper |
|
36508 | 38 |
* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI |
55206 | 39 |
* -XX:-UseJVMCICompiler |
36508 | 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 |
|
41325 | 78 |
result.add(new TestCase(true, SingleSubclass.class, "usualMethod")); |
33160 | 79 |
// overriden method |
41325 | 80 |
result.add(new TestCase(true, SingleSubclass.class, "overridenMethod")); |
33160 | 81 |
// private method |
55298
1fe17d2be502
8223050: JVMCI: findUniqueConcreteMethod() should not use Dependencies::find_unique_concrete_method() for non-virtual methods
dlong
parents:
55206
diff
changeset
|
82 |
result.add(new TestCase(InternalError.class, SingleSubclass.class, "privateMethod")); |
33160 | 83 |
// protected method |
41325 | 84 |
result.add(new TestCase(true, SingleSubclass.class, "protectedMethod")); |
33160 | 85 |
// default(package-private) method |
41325 | 86 |
result.add(new TestCase(true, SingleSubclass.class, "defaultAccessMethod")); |
33160 | 87 |
// default interface method redefined in implementer |
41325 | 88 |
result.add(new TestCase(true, MultipleImplementer1.class, "defaultMethod")); |
33160 | 89 |
// interface method |
41325 | 90 |
result.add(new TestCase(true, MultipleImplementer1.class, "testMethod")); |
33160 | 91 |
// default interface method not redefined in implementer |
41325 | 92 |
// result.add(new TestCase(true, SingleImplementer.class, |
93 |
// SingleImplementerInterface.class, "defaultMethod")); |
|
33160 | 94 |
// static method |
55298
1fe17d2be502
8223050: JVMCI: findUniqueConcreteMethod() should not use Dependencies::find_unique_concrete_method() for non-virtual methods
dlong
parents:
55206
diff
changeset
|
95 |
result.add(new TestCase(InternalError.class, SingleSubclass.class, "staticMethod")); |
40362
94addd7cfa10
8162477: [JVMCI] assert(wf.check_method_context(ctxk, m)) failed: proper context
never
parents:
40059
diff
changeset
|
96 |
// interface method |
94addd7cfa10
8162477: [JVMCI] assert(wf.check_method_context(ctxk, m)) failed: proper context
never
parents:
40059
diff
changeset
|
97 |
result.add(new TestCase(false, MultipleSuperImplementers.class, |
41325 | 98 |
DuplicateSimpleSingleImplementerInterface.class, "interfaceMethod")); |
40362
94addd7cfa10
8162477: [JVMCI] assert(wf.check_method_context(ctxk, m)) failed: proper context
never
parents:
40059
diff
changeset
|
99 |
result.add(new TestCase(false, MultipleSuperImplementers.class, |
41325 | 100 |
SimpleSingleImplementerInterface.class, "interfaceMethod")); |
33160 | 101 |
return result; |
102 |
} |
|
103 |
||
104 |
private void runTest(TestCase tcase) throws NoSuchMethodException { |
|
105 |
System.out.println(tcase); |
|
106 |
Method method = tcase.holder.getDeclaredMethod(tcase.methodName); |
|
41325 | 107 |
HotSpotResolvedJavaMethod testMethod = CTVMUtilities.getResolvedMethod(method); |
108 |
||
33632 | 109 |
HotSpotResolvedObjectType resolvedType = CompilerToVMHelper |
46972
3e88de95fccf
8186459: [JVMCI] ClassNotFoundException thrown by CompilerToVM.lookupType() should be converted to a LinkageError
dnsimon
parents:
44836
diff
changeset
|
110 |
.lookupTypeHelper(Utils.toJVMTypeSignature(tcase.receiver), getClass(), |
33160 | 111 |
/* resolve = */ true); |
55298
1fe17d2be502
8223050: JVMCI: findUniqueConcreteMethod() should not use Dependencies::find_unique_concrete_method() for non-virtual methods
dlong
parents:
55206
diff
changeset
|
112 |
if (tcase.exception != null) { |
1fe17d2be502
8223050: JVMCI: findUniqueConcreteMethod() should not use Dependencies::find_unique_concrete_method() for non-virtual methods
dlong
parents:
55206
diff
changeset
|
113 |
try { |
1fe17d2be502
8223050: JVMCI: findUniqueConcreteMethod() should not use Dependencies::find_unique_concrete_method() for non-virtual methods
dlong
parents:
55206
diff
changeset
|
114 |
HotSpotResolvedJavaMethod concreteMethod = CompilerToVMHelper |
1fe17d2be502
8223050: JVMCI: findUniqueConcreteMethod() should not use Dependencies::find_unique_concrete_method() for non-virtual methods
dlong
parents:
55206
diff
changeset
|
115 |
.findUniqueConcreteMethod(resolvedType, testMethod); |
1fe17d2be502
8223050: JVMCI: findUniqueConcreteMethod() should not use Dependencies::find_unique_concrete_method() for non-virtual methods
dlong
parents:
55206
diff
changeset
|
116 |
|
1fe17d2be502
8223050: JVMCI: findUniqueConcreteMethod() should not use Dependencies::find_unique_concrete_method() for non-virtual methods
dlong
parents:
55206
diff
changeset
|
117 |
Asserts.fail("Exception " + tcase.exception.getName() + " not thrown for " + tcase.methodName); |
1fe17d2be502
8223050: JVMCI: findUniqueConcreteMethod() should not use Dependencies::find_unique_concrete_method() for non-virtual methods
dlong
parents:
55206
diff
changeset
|
118 |
} catch (Throwable t) { |
1fe17d2be502
8223050: JVMCI: findUniqueConcreteMethod() should not use Dependencies::find_unique_concrete_method() for non-virtual methods
dlong
parents:
55206
diff
changeset
|
119 |
Asserts.assertEQ(t.getClass(), tcase.exception, "Wrong exception thrown for " + tcase.methodName); |
1fe17d2be502
8223050: JVMCI: findUniqueConcreteMethod() should not use Dependencies::find_unique_concrete_method() for non-virtual methods
dlong
parents:
55206
diff
changeset
|
120 |
} |
1fe17d2be502
8223050: JVMCI: findUniqueConcreteMethod() should not use Dependencies::find_unique_concrete_method() for non-virtual methods
dlong
parents:
55206
diff
changeset
|
121 |
} else { |
1fe17d2be502
8223050: JVMCI: findUniqueConcreteMethod() should not use Dependencies::find_unique_concrete_method() for non-virtual methods
dlong
parents:
55206
diff
changeset
|
122 |
HotSpotResolvedJavaMethod concreteMethod = CompilerToVMHelper |
1fe17d2be502
8223050: JVMCI: findUniqueConcreteMethod() should not use Dependencies::find_unique_concrete_method() for non-virtual methods
dlong
parents:
55206
diff
changeset
|
123 |
.findUniqueConcreteMethod(resolvedType, testMethod); |
1fe17d2be502
8223050: JVMCI: findUniqueConcreteMethod() should not use Dependencies::find_unique_concrete_method() for non-virtual methods
dlong
parents:
55206
diff
changeset
|
124 |
Asserts.assertEQ(concreteMethod, tcase.isPositive ? testMethod : null, |
1fe17d2be502
8223050: JVMCI: findUniqueConcreteMethod() should not use Dependencies::find_unique_concrete_method() for non-virtual methods
dlong
parents:
55206
diff
changeset
|
125 |
"Unexpected concrete method for " + tcase.methodName); |
1fe17d2be502
8223050: JVMCI: findUniqueConcreteMethod() should not use Dependencies::find_unique_concrete_method() for non-virtual methods
dlong
parents:
55206
diff
changeset
|
126 |
} |
33160 | 127 |
} |
128 |
||
129 |
private static class TestCase { |
|
33632 | 130 |
public final Class<?> receiver; |
33160 | 131 |
public final Class<?> holder; |
132 |
public final String methodName; |
|
133 |
public final boolean isPositive; |
|
55298
1fe17d2be502
8223050: JVMCI: findUniqueConcreteMethod() should not use Dependencies::find_unique_concrete_method() for non-virtual methods
dlong
parents:
55206
diff
changeset
|
134 |
public final Class<?> exception; |
33160 | 135 |
|
136 |
public TestCase(boolean isPositive, Class<?> clazz, Class<?> holder, |
|
55298
1fe17d2be502
8223050: JVMCI: findUniqueConcreteMethod() should not use Dependencies::find_unique_concrete_method() for non-virtual methods
dlong
parents:
55206
diff
changeset
|
137 |
String methodName, Class<?> exception) { |
33632 | 138 |
this.receiver = clazz; |
33160 | 139 |
this.methodName = methodName; |
140 |
this.isPositive = isPositive; |
|
141 |
this.holder = holder; |
|
55298
1fe17d2be502
8223050: JVMCI: findUniqueConcreteMethod() should not use Dependencies::find_unique_concrete_method() for non-virtual methods
dlong
parents:
55206
diff
changeset
|
142 |
this.exception = exception; |
1fe17d2be502
8223050: JVMCI: findUniqueConcreteMethod() should not use Dependencies::find_unique_concrete_method() for non-virtual methods
dlong
parents:
55206
diff
changeset
|
143 |
} |
1fe17d2be502
8223050: JVMCI: findUniqueConcreteMethod() should not use Dependencies::find_unique_concrete_method() for non-virtual methods
dlong
parents:
55206
diff
changeset
|
144 |
|
1fe17d2be502
8223050: JVMCI: findUniqueConcreteMethod() should not use Dependencies::find_unique_concrete_method() for non-virtual methods
dlong
parents:
55206
diff
changeset
|
145 |
public TestCase(boolean isPositive, Class<?> clazz, Class<?> holder, |
1fe17d2be502
8223050: JVMCI: findUniqueConcreteMethod() should not use Dependencies::find_unique_concrete_method() for non-virtual methods
dlong
parents:
55206
diff
changeset
|
146 |
String methodName) { |
1fe17d2be502
8223050: JVMCI: findUniqueConcreteMethod() should not use Dependencies::find_unique_concrete_method() for non-virtual methods
dlong
parents:
55206
diff
changeset
|
147 |
this(isPositive, clazz, holder, methodName, null); |
40362
94addd7cfa10
8162477: [JVMCI] assert(wf.check_method_context(ctxk, m)) failed: proper context
never
parents:
40059
diff
changeset
|
148 |
} |
94addd7cfa10
8162477: [JVMCI] assert(wf.check_method_context(ctxk, m)) failed: proper context
never
parents:
40059
diff
changeset
|
149 |
|
41325 | 150 |
public TestCase(boolean isPositive, Class<?> clazz, String methodName) { |
55298
1fe17d2be502
8223050: JVMCI: findUniqueConcreteMethod() should not use Dependencies::find_unique_concrete_method() for non-virtual methods
dlong
parents:
55206
diff
changeset
|
151 |
this(isPositive, clazz, clazz, methodName, null); |
1fe17d2be502
8223050: JVMCI: findUniqueConcreteMethod() should not use Dependencies::find_unique_concrete_method() for non-virtual methods
dlong
parents:
55206
diff
changeset
|
152 |
} |
1fe17d2be502
8223050: JVMCI: findUniqueConcreteMethod() should not use Dependencies::find_unique_concrete_method() for non-virtual methods
dlong
parents:
55206
diff
changeset
|
153 |
|
1fe17d2be502
8223050: JVMCI: findUniqueConcreteMethod() should not use Dependencies::find_unique_concrete_method() for non-virtual methods
dlong
parents:
55206
diff
changeset
|
154 |
public TestCase(Class<?> exception, Class<?> clazz, String methodName) { |
1fe17d2be502
8223050: JVMCI: findUniqueConcreteMethod() should not use Dependencies::find_unique_concrete_method() for non-virtual methods
dlong
parents:
55206
diff
changeset
|
155 |
this(false, clazz, clazz, methodName, exception); |
33160 | 156 |
} |
157 |
||
158 |
@Override |
|
159 |
public String toString() { |
|
55298
1fe17d2be502
8223050: JVMCI: findUniqueConcreteMethod() should not use Dependencies::find_unique_concrete_method() for non-virtual methods
dlong
parents:
55206
diff
changeset
|
160 |
return String.format("CASE: receiver=%s, holder=%s, method=%s, isPositive=%s, exception=%s", |
1fe17d2be502
8223050: JVMCI: findUniqueConcreteMethod() should not use Dependencies::find_unique_concrete_method() for non-virtual methods
dlong
parents:
55206
diff
changeset
|
161 |
receiver.getName(), holder.getName(), methodName, isPositive, |
1fe17d2be502
8223050: JVMCI: findUniqueConcreteMethod() should not use Dependencies::find_unique_concrete_method() for non-virtual methods
dlong
parents:
55206
diff
changeset
|
162 |
exception == null ? "<none>" : exception.getName()); |
33160 | 163 |
} |
164 |
} |
|
165 |
} |