# HG changeset patch # User Doug Simon # Date 1405028945 -7200 # Node ID 890d25ac05c33aa2ef30c88416d30b6e84da4a87 # Parent 1ffe4349f945f4bfb0fc8d1bf343fe864f72c284 moved getParameterAnnotations(Class annotationClass, ResolvedJavaMethod method) from MetaUtil to be a default method in ResolvedJavaMethod diff -r 1ffe4349f945 -r 890d25ac05c3 graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/MetaUtil.java --- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/MetaUtil.java Thu Jul 10 23:45:16 2014 +0200 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/MetaUtil.java Thu Jul 10 23:49:05 2014 +0200 @@ -23,8 +23,6 @@ package com.oracle.graal.api.meta; import java.io.*; -import java.lang.annotation.*; -import java.lang.reflect.*; import java.util.*; import com.oracle.graal.api.meta.ProfilingInfo.TriState; @@ -225,28 +223,6 @@ } /** - * Gets the annotations of a particular type for the formal parameters of a given method. - * - * @param annotationClass the Class object corresponding to the annotation type - * @param method the method for which a parameter annotations are being requested - * @return the annotation of type {@code annotationClass} (if any) for each formal parameter - * present - */ - @SuppressWarnings("unchecked") - public static T[] getParameterAnnotations(Class annotationClass, ResolvedJavaMethod method) { - Annotation[][] parameterAnnotations = method.getParameterAnnotations(); - T[] result = (T[]) Array.newInstance(annotationClass, parameterAnnotations.length); - for (int i = 0; i < parameterAnnotations.length; i++) { - for (Annotation a : parameterAnnotations[i]) { - if (a.annotationType() == annotationClass) { - result[i] = annotationClass.cast(a); - } - } - } - return result; - } - - /** * Convenient shortcut for calling * {@link #appendLocation(StringBuilder, ResolvedJavaMethod, int)} without having to supply a a * {@link StringBuilder} instance and convert the result to a string. diff -r 1ffe4349f945 -r 890d25ac05c3 graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaMethod.java --- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaMethod.java Thu Jul 10 23:45:16 2014 +0200 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaMethod.java Thu Jul 10 23:49:05 2014 +0200 @@ -252,4 +252,25 @@ return getSignature().toParameterTypes(receiver); } + /** + * Gets the annotations of a particular type for the formal parameters of this method. + * + * @param annotationClass the Class object corresponding to the annotation type + * @return the annotation of type {@code annotationClass} (if any) for each formal parameter + * present + */ + @SuppressWarnings("unchecked") + default T[] getParameterAnnotations(Class annotationClass) { + Annotation[][] parameterAnnotations = getParameterAnnotations(); + T[] result = (T[]) Array.newInstance(annotationClass, parameterAnnotations.length); + for (int i = 0; i < parameterAnnotations.length; i++) { + for (Annotation a : parameterAnnotations[i]) { + if (a.annotationType() == annotationClass) { + result[i] = annotationClass.cast(a); + } + } + } + return result; + } + } diff -r 1ffe4349f945 -r 890d25ac05c3 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Thu Jul 10 23:45:16 2014 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Thu Jul 10 23:49:05 2014 +0200 @@ -496,7 +496,7 @@ * Determines if any parameter of a given method is annotated with {@link ConstantParameter}. */ public static boolean hasConstantParameter(ResolvedJavaMethod method) { - for (ConstantParameter p : MetaUtil.getParameterAnnotations(ConstantParameter.class, method)) { + for (ConstantParameter p : method.getParameterAnnotations(ConstantParameter.class)) { if (p != null) { return true; }