changeset 20848:0c1cd72188dc

fail fast(er) if the target method of an InvocationPlugin does not exist
author Doug Simon <doug.simon@oracle.com>
date Wed, 08 Apr 2015 00:03:10 +0200
parents f2a357ee14e4
children 91f44f419e29
files graal/com.oracle.graal.graphbuilderconf/src/com/oracle/graal/graphbuilderconf/InvocationPlugins.java
diffstat 1 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.graphbuilderconf/src/com/oracle/graal/graphbuilderconf/InvocationPlugins.java	Tue Apr 07 18:02:05 2015 +0200
+++ b/graal/com.oracle.graal.graphbuilderconf/src/com/oracle/graal/graphbuilderconf/InvocationPlugins.java	Wed Apr 08 00:03:10 2015 +0200
@@ -213,6 +213,7 @@
             if (!isStatic) {
                 argumentTypes[0] = declaringClass;
             }
+            assert resolveJava() != null;
         }
 
         @Override
@@ -233,16 +234,20 @@
         }
 
         ResolvedJavaMethod resolve(MetaAccessProvider metaAccess) {
+            return metaAccess.lookupJavaMethod(resolveJava());
+        }
+
+        Executable resolveJava() {
             try {
-                ResolvedJavaMethod method;
+                Executable res;
                 Class<?>[] parameterTypes = isStatic ? argumentTypes : Arrays.copyOfRange(argumentTypes, 1, argumentTypes.length);
                 if (name.equals("<init>")) {
-                    method = metaAccess.lookupJavaMethod(declaringClass.getDeclaredConstructor(parameterTypes));
+                    res = declaringClass.getDeclaredConstructor(parameterTypes);
                 } else {
-                    method = metaAccess.lookupJavaMethod(declaringClass.getDeclaredMethod(name, parameterTypes));
+                    res = declaringClass.getDeclaredMethod(name, parameterTypes);
                 }
-                assert method.isStatic() == isStatic;
-                return method;
+                assert Modifier.isStatic(res.getModifiers()) == isStatic;
+                return res;
             } catch (NoSuchMethodException | SecurityException e) {
                 throw new GraalInternalError(e);
             }