changeset 17125:ce1b6453c544

Add ResolvedJavaMethod.getAnnotations
author Christian Wimmer <christian.wimmer@oracle.com>
date Tue, 16 Sep 2014 18:36:59 -0700
parents 7b3ece800806
children 7a0bff31df98
files graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaMethod.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java
diffstat 2 files changed, 16 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaMethod.java	Tue Sep 16 18:36:19 2014 -0700
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaMethod.java	Tue Sep 16 18:36:59 2014 -0700
@@ -141,6 +141,12 @@
     ConstantPool getConstantPool();
 
     /**
+     * Returns all annotations of this method. If no annotations are present, an array of length 0
+     * is returned.
+     */
+    Annotation[] getAnnotations();
+
+    /**
      * Returns the annotation for the specified type of this method, if such an annotation is
      * present.
      *
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java	Tue Sep 16 18:36:19 2014 -0700
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java	Tue Sep 16 18:36:59 2014 -0700
@@ -461,6 +461,16 @@
     }
 
     @Override
+    public Annotation[] getAnnotations() {
+        if (isConstructor()) {
+            Constructor<?> javaConstructor = toJavaConstructor();
+            return javaConstructor == null ? new Annotation[0] : javaConstructor.getAnnotations();
+        }
+        Method javaMethod = toJava();
+        return javaMethod == null ? new Annotation[0] : javaMethod.getAnnotations();
+    }
+
+    @Override
     public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
         if (isConstructor()) {
             Constructor<?> javaConstructor = toJavaConstructor();