changeset 20117:20d39cfa8f1b

improved error message for use of a macro node within a snippet that tries to lower itself to an invoke
author Doug Simon <doug.simon@oracle.com>
date Wed, 01 Apr 2015 15:08:25 +0200
parents 674a81af7992
children 3d3e16f6077a
files graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java	Wed Apr 01 13:59:01 2015 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java	Wed Apr 01 15:08:25 2015 +0200
@@ -171,7 +171,16 @@
             Debug.dump(graph(), "After inlining replacement %s", replacementGraph);
         } else {
             if (invoke.stateAfter() == null) {
-                throw new GraalInternalError("cannot lower to invoke without state: %s", this);
+                ResolvedJavaMethod method = graph().method();
+                if (method.getAnnotation(MethodSubstitution.class) != null || method.getAnnotation(Snippet.class) != null) {
+                    // One cause for this is that a MacroNode is created for a method that
+                    // no longer needs a MacroNode. For example, Class.getComponentType()
+                    // only needs a MacroNode prior to JDK9 as it was given a non-native
+                    // implementation in JDK9.
+                    throw new GraalInternalError("%s macro created for call to %s in %s must be lowerable to a snippet or intrinsic graph. "
+                                    + "Maybe a macro node is not needed for this method in the current JDK?", getClass().getSimpleName(), targetMethod.format("%h.%n(%p)"), graph());
+                }
+                throw new GraalInternalError("%s: cannot lower to invoke without state: %s", graph(), this);
             }
             invoke.lower(tool);
         }