Skip to content

Commit 04ca660

Browse files
author
Doug Simon
committed
8253874: [JVMCI] added test omitted in 8252881
Reviewed-by: shade
1 parent 49128a1 commit 04ca660

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java

+27-6
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@
8383
/**
8484
* Tests for {@link ResolvedJavaType}.
8585
*/
86-
@SuppressWarnings("unchecked")
8786
public class TestResolvedJavaType extends TypeUniverse {
8887
private static final Class<? extends Annotation> SIGNATURE_POLYMORPHIC_CLASS = findPolymorphicSignatureClass();
8988

9089
public TestResolvedJavaType() {
9190
}
9291

92+
@SuppressWarnings("unchecked")
9393
private static Class<? extends Annotation> findPolymorphicSignatureClass() {
9494
Class<? extends Annotation> signaturePolyAnnotation = null;
9595
try {
@@ -185,8 +185,10 @@ public void getHostClassTest() throws Exception {
185185
}
186186
}
187187

188-
class LocalClass {}
189-
Cloneable clone = new Cloneable() {};
188+
class LocalClass {
189+
}
190+
Cloneable clone = new Cloneable() {
191+
};
190192
assertNull(metaAccess.lookupJavaType(LocalClass.class).getHostClass());
191193
assertNull(metaAccess.lookupJavaType(clone.getClass()).getHostClass());
192194

@@ -771,17 +773,36 @@ public void resolveMethodTest() {
771773
for (Method decl : decls) {
772774
ResolvedJavaMethod m = metaAccess.lookupJavaMethod(decl);
773775
if (m.isPublic()) {
774-
ResolvedJavaMethod resolvedmethod = type.resolveMethod(m, context);
776+
ResolvedJavaMethod resolvedMethod = type.resolveMethod(m, context);
775777
if (isSignaturePolymorphic(m)) {
776778
// Signature polymorphic methods must not be resolved
777-
assertNull(resolvedmethod);
779+
assertNull(resolvedMethod);
778780
} else {
779781
ResolvedJavaMethod i = metaAccess.lookupJavaMethod(impl);
780-
assertEquals(m.toString(), i, resolvedmethod);
782+
assertEquals(m.toString(), i, resolvedMethod);
781783
}
782784
}
783785
}
784786
}
787+
// For backwards compatibility treat constructors as resolvable even though they
788+
// aren't virtually dispatched.
789+
ResolvedJavaType declaringClass = metaAccess.lookupJavaType(c);
790+
for (Constructor<?> m : c.getDeclaredConstructors()) {
791+
ResolvedJavaMethod decl = metaAccess.lookupJavaMethod(m);
792+
ResolvedJavaMethod impl = type.resolveMethod(decl, declaringClass);
793+
assertEquals(m.toString(), decl, impl);
794+
}
795+
for (Method m : c.getDeclaredMethods()) {
796+
if (isStatic(m.getModifiers())) {
797+
// resolveMethod really shouldn't be called with static methods and the
798+
// result is is somewhat inconsistent so just ignore them
799+
continue;
800+
}
801+
ResolvedJavaMethod decl = metaAccess.lookupJavaMethod(m);
802+
ResolvedJavaMethod impl = type.resolveMethod(decl, declaringClass);
803+
ResolvedJavaMethod expected = isSignaturePolymorphic(decl) ? null : decl;
804+
assertEquals(m.toString(), expected, impl);
805+
}
785806
}
786807
}
787808
}

0 commit comments

Comments
 (0)