< prev index next >

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

Print this page

        

*** 581,621 **** } } return declarations; } - private static void checkResolveMethod(ResolvedJavaType type, ResolvedJavaType context, ResolvedJavaMethod decl, ResolvedJavaMethod expected) { - ResolvedJavaMethod impl = type.resolveConcreteMethod(decl, context); - assertEquals(expected, impl); - } - @Test public void resolveMethodTest() { ResolvedJavaType context = metaAccess.lookupJavaType(TestResolvedJavaType.class); for (Class<?> c : classes) { - if (c.isInterface() || c.isPrimitive()) { ResolvedJavaType type = metaAccess.lookupJavaType(c); for (Method m : c.getDeclaredMethods()) { - if (JAVA_VERSION <= 1.7D || (!isStatic(m.getModifiers()) && !isPrivate(m.getModifiers()))) { ResolvedJavaMethod resolved = metaAccess.lookupJavaMethod(m); ResolvedJavaMethod impl = type.resolveMethod(resolved, context); ! ResolvedJavaMethod expected = resolved.isDefault() || resolved.isAbstract() ? resolved : null; ! assertEquals(m.toString(), expected, impl); ! } else { ! // As of JDK 8, interfaces can have static and private methods ! } } } else { - ResolvedJavaType type = metaAccess.lookupJavaType(c); VTable vtable = getVTable(c); for (Method impl : vtable.methods.values()) { Set<Method> decls = findDeclarations(impl, c); for (Method decl : decls) { ResolvedJavaMethod m = metaAccess.lookupJavaMethod(decl); if (m.isPublic()) { ResolvedJavaMethod i = metaAccess.lookupJavaMethod(impl); ! checkResolveMethod(type, context, m, i); } } } } } --- 581,612 ---- } } return declarations; } @Test public void resolveMethodTest() { ResolvedJavaType context = metaAccess.lookupJavaType(TestResolvedJavaType.class); for (Class<?> c : classes) { ResolvedJavaType type = metaAccess.lookupJavaType(c); + if (c.isInterface()) { for (Method m : c.getDeclaredMethods()) { ResolvedJavaMethod resolved = metaAccess.lookupJavaMethod(m); ResolvedJavaMethod impl = type.resolveMethod(resolved, context); ! assertEquals(m.toString(), null, impl); } + } else if (c.isPrimitive()) { + assertEquals("No methods expected", c.getDeclaredMethods().length, 0); } else { VTable vtable = getVTable(c); for (Method impl : vtable.methods.values()) { Set<Method> decls = findDeclarations(impl, c); for (Method decl : decls) { ResolvedJavaMethod m = metaAccess.lookupJavaMethod(decl); if (m.isPublic()) { ResolvedJavaMethod i = metaAccess.lookupJavaMethod(impl); ! assertEquals(m.toString(), i, type.resolveMethod(m, context)); } } } } }
*** 623,654 **** @Test public void resolveConcreteMethodTest() { ResolvedJavaType context = metaAccess.lookupJavaType(TestResolvedJavaType.class); for (Class<?> c : classes) { - if (c.isInterface() || c.isPrimitive()) { ResolvedJavaType type = metaAccess.lookupJavaType(c); for (Method m : c.getDeclaredMethods()) { - if (JAVA_VERSION <= 1.7D || (!isStatic(m.getModifiers()) && !isPrivate(m.getModifiers()))) { ResolvedJavaMethod resolved = metaAccess.lookupJavaMethod(m); ResolvedJavaMethod impl = type.resolveConcreteMethod(resolved, context); ! ResolvedJavaMethod expected = resolved.isDefault() ? resolved : null; ! assertEquals(m.toString(), expected, impl); ! } else { ! // As of JDK 8, interfaces can have static and private methods ! } } } else { - ResolvedJavaType type = metaAccess.lookupJavaType(c); VTable vtable = getVTable(c); for (Method impl : vtable.methods.values()) { Set<Method> decls = findDeclarations(impl, c); for (Method decl : decls) { ResolvedJavaMethod m = metaAccess.lookupJavaMethod(decl); if (m.isPublic()) { ResolvedJavaMethod i = metaAccess.lookupJavaMethod(impl); ! checkResolveMethod(type, context, m, i); } } } for (Method m : c.getDeclaredMethods()) { ResolvedJavaMethod impl = type.resolveConcreteMethod(metaAccess.lookupJavaMethod(m), context); --- 614,641 ---- @Test public void resolveConcreteMethodTest() { ResolvedJavaType context = metaAccess.lookupJavaType(TestResolvedJavaType.class); for (Class<?> c : classes) { ResolvedJavaType type = metaAccess.lookupJavaType(c); + if (c.isInterface()) { for (Method m : c.getDeclaredMethods()) { ResolvedJavaMethod resolved = metaAccess.lookupJavaMethod(m); ResolvedJavaMethod impl = type.resolveConcreteMethod(resolved, context); ! assertEquals(m.toString(), null, impl); } + } else if (c.isPrimitive()) { + assertEquals("No methods expected", c.getDeclaredMethods().length, 0); } else { VTable vtable = getVTable(c); for (Method impl : vtable.methods.values()) { Set<Method> decls = findDeclarations(impl, c); for (Method decl : decls) { ResolvedJavaMethod m = metaAccess.lookupJavaMethod(decl); if (m.isPublic()) { ResolvedJavaMethod i = metaAccess.lookupJavaMethod(impl); ! assertEquals(i, type.resolveConcreteMethod(m, context)); } } } for (Method m : c.getDeclaredMethods()) { ResolvedJavaMethod impl = type.resolveConcreteMethod(metaAccess.lookupJavaMethod(m), context);
< prev index next >