Skip to content

Commit

Permalink
8253874: [JVMCI] added test omitted in 8252881
Browse files Browse the repository at this point in the history
Reviewed-by: shade
  • Loading branch information
Doug Simon committed Oct 7, 2020
1 parent 49128a1 commit 04ca660
Showing 1 changed file with 27 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@
/**
* 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 {
Expand Down Expand Up @@ -185,8 +185,10 @@ public void getHostClassTest() throws Exception {
}
}

class LocalClass {}
Cloneable clone = new Cloneable() {};
class LocalClass {
}
Cloneable clone = new Cloneable() {
};
assertNull(metaAccess.lookupJavaType(LocalClass.class).getHostClass());
assertNull(metaAccess.lookupJavaType(clone.getClass()).getHostClass());

Expand Down Expand Up @@ -771,17 +773,36 @@ public void resolveMethodTest() {
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);
}
}
}
}
Expand Down

1 comment on commit 04ca660

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented on 04ca660 Oct 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.