8253874: [JVMCI] added test omitted in 8252881

Reviewed-by: shade
This commit is contained in:
Doug Simon 2020-10-07 09:14:43 +00:00
parent 49128a1ee5
commit 04ca660e81

View File

@ -83,13 +83,13 @@ import jdk.vm.ci.meta.ResolvedJavaType;
/**
* Tests for {@link ResolvedJavaType}.
*/
@SuppressWarnings("unchecked")
public class TestResolvedJavaType extends TypeUniverse {
private static final Class<? extends Annotation> SIGNATURE_POLYMORPHIC_CLASS = findPolymorphicSignatureClass();
public TestResolvedJavaType() {
}
@SuppressWarnings("unchecked")
private static Class<? extends Annotation> findPolymorphicSignatureClass() {
Class<? extends Annotation> signaturePolyAnnotation = null;
try {
@ -185,8 +185,10 @@ public class TestResolvedJavaType extends TypeUniverse {
}
}
class LocalClass {}
Cloneable clone = new Cloneable() {};
class LocalClass {
}
Cloneable clone = new Cloneable() {
};
assertNull(metaAccess.lookupJavaType(LocalClass.class).getHostClass());
assertNull(metaAccess.lookupJavaType(clone.getClass()).getHostClass());
@ -771,17 +773,36 @@ public class TestResolvedJavaType extends TypeUniverse {
for (Method decl : decls) {
ResolvedJavaMethod m = metaAccess.lookupJavaMethod(decl);
if (m.isPublic()) {
ResolvedJavaMethod resolvedmethod = type.resolveMethod(m, context);
ResolvedJavaMethod resolvedMethod = type.resolveMethod(m, context);
if (isSignaturePolymorphic(m)) {
// Signature polymorphic methods must not be resolved
assertNull(resolvedmethod);
assertNull(resolvedMethod);
} else {
ResolvedJavaMethod i = metaAccess.lookupJavaMethod(impl);
assertEquals(m.toString(), i, resolvedmethod);
assertEquals(m.toString(), i, resolvedMethod);
}
}
}
}
// For backwards compatibility treat constructors as resolvable even though they
// aren't virtually dispatched.
ResolvedJavaType declaringClass = metaAccess.lookupJavaType(c);
for (Constructor<?> m : c.getDeclaredConstructors()) {
ResolvedJavaMethod decl = metaAccess.lookupJavaMethod(m);
ResolvedJavaMethod impl = type.resolveMethod(decl, declaringClass);
assertEquals(m.toString(), decl, impl);
}
for (Method m : c.getDeclaredMethods()) {
if (isStatic(m.getModifiers())) {
// resolveMethod really shouldn't be called with static methods and the
// result is is somewhat inconsistent so just ignore them
continue;
}
ResolvedJavaMethod decl = metaAccess.lookupJavaMethod(m);
ResolvedJavaMethod impl = type.resolveMethod(decl, declaringClass);
ResolvedJavaMethod expected = isSignaturePolymorphic(decl) ? null : decl;
assertEquals(m.toString(), expected, impl);
}
}
}
}