changeset 11952:c0807f5fdca5

added ResolvedJavaType.getClassInititalizer()
author Doug Simon <doug.simon@oracle.com>
date Thu, 10 Oct 2013 11:55:46 +0200
parents c0c616fe3588
children f9f18098479e
files graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaType.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java
diffstat 3 files changed, 18 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaType.java	Thu Oct 10 03:23:40 2013 +0200
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaType.java	Thu Oct 10 11:55:46 2013 +0200
@@ -301,6 +301,11 @@
     ResolvedJavaMethod[] getDeclaredMethods();
 
     /**
+     * Returns the {@code <clinit>} method for this class if there is one.
+     */
+    ResolvedJavaMethod getClassInitializer();
+
+    /**
      * Creates a new array with this type as the component type and the specified length. This
      * method is similar to {@link Array#newInstance(Class, int)}.
      */
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java	Thu Oct 10 03:23:40 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java	Thu Oct 10 11:55:46 2013 +0200
@@ -561,13 +561,14 @@
         return result;
     }
 
-    /**
-     * Gets all methods and constructors declared by this class, including the {@code <clinit>}
-     * method if there is one. The latter is not made accessible via standard Java reflection.
-     */
-    public ResolvedJavaMethod[] getMethods() {
-        HotSpotResolvedJavaMethod[] methods = graalRuntime().getCompilerToVM().getMethods(this);
-        return methods;
+    public ResolvedJavaMethod getClassInitializer() {
+        ResolvedJavaMethod[] methods = graalRuntime().getCompilerToVM().getMethods(this);
+        for (ResolvedJavaMethod m : methods) {
+            if (m.isClassInitializer()) {
+                return m;
+            }
+        }
+        return null;
     }
 
     @Override
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java	Thu Oct 10 03:23:40 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java	Thu Oct 10 11:55:46 2013 +0200
@@ -227,6 +227,11 @@
     }
 
     @Override
+    public ResolvedJavaMethod getClassInitializer() {
+        return null;
+    }
+
+    @Override
     public Constant newArray(int length) {
         return Constant.forObject(Array.newInstance(javaMirror, length));
     }