changeset 11953:f9f18098479e

added tests for ResolvedJavaType.getClassInitializer() and ResolvedJavaType.getDeclaredMethods()
author Doug Simon <doug.simon@oracle.com>
date Thu, 10 Oct 2013 11:56:25 +0200
parents c0807f5fdca5
children 905c26108117
files graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestResolvedJavaType.java
diffstat 1 files changed, 43 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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<ResolvedJavaMethod> expected = new HashSet<>();
+            for (Method m : raw) {
+                ResolvedJavaMethod resolvedMethod = runtime.lookupJavaMethod(m);
+                assertNotNull(resolvedMethod);
+                expected.add(resolvedMethod);
+            }
+            Set<ResolvedJavaMethod> 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 <clinit>
+            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",