# HG changeset patch # User Doug Simon # Date 1381398985 -7200 # Node ID f9f18098479ee9699abea6255b2c307b94728cfe # Parent c0807f5fdca59beb4f49eaaaeb3424f0a6b9671f added tests for ResolvedJavaType.getClassInitializer() and ResolvedJavaType.getDeclaredMethods() diff -r c0807f5fdca5 -r f9f18098479e graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestResolvedJavaType.java --- a/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestResolvedJavaType.java Thu Oct 10 11:55:46 2013 +0200 +++ b/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestResolvedJavaType.java Thu Oct 10 11:56:25 2013 +0200 @@ -548,6 +548,49 @@ } @Test + public void getDeclaredMethodsTest() { + for (Class c : classes) { + ResolvedJavaType type = runtime.lookupJavaType(c); + Method[] raw = c.getDeclaredMethods(); + Set expected = new HashSet<>(); + for (Method m : raw) { + ResolvedJavaMethod resolvedMethod = runtime.lookupJavaMethod(m); + assertNotNull(resolvedMethod); + expected.add(resolvedMethod); + } + Set actual = new HashSet<>(Arrays.asList(type.getDeclaredMethods())); + assertEquals(expected, actual); + } + } + + static class A { + static String name = "foo"; + } + + static class B extends A { + } + + static class C { + } + + static class D { + void foo() { + // use of assertions causes the class to have a + assert getClass() != null; + } + } + + @Test + public void getClassInitializerTest() { + assertNotNull(runtime.lookupJavaType(A.class).getClassInitializer()); + assertNotNull(runtime.lookupJavaType(D.class).getClassInitializer()); + assertNull(runtime.lookupJavaType(B.class).getClassInitializer()); + assertNull(runtime.lookupJavaType(C.class).getClassInitializer()); + assertNull(runtime.lookupJavaType(int.class).getClassInitializer()); + assertNull(runtime.lookupJavaType(void.class).getClassInitializer()); + } + + @Test public void getAnnotationTest() { for (Class c : classes) { ResolvedJavaType type = runtime.lookupJavaType(c); @@ -604,7 +647,6 @@ "initialize", "isPrimitive", "newArray", - "getDeclaredMethods", "getDeclaredConstructors", "isInitialized", "isLinked",