changeset 16827:5e647663b77e

instances of generated Node classes are created with static factory methods
author Doug Simon <doug.simon@oracle.com>
date Wed, 13 Aug 2014 21:57:12 +0200
parents e5e45c74d95e
children 2834af86f398
files graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java	Wed Aug 13 21:28:23 2014 +0200
+++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java	Wed Aug 13 21:57:12 2014 +0200
@@ -335,8 +335,13 @@
      */
     private static ValueNode createBinaryNodeInstance(Class<? extends ValueNode> nodeClass, ValueNode left, ValueNode right) {
         try {
-            Constructor<? extends ValueNode> constructor = nodeClass.getConstructor(ValueNode.class, ValueNode.class);
-            return constructor.newInstance(left, right);
+            try {
+                Constructor<? extends ValueNode> constructor = nodeClass.getConstructor(ValueNode.class, ValueNode.class);
+                return constructor.newInstance(left, right);
+            } catch (NoSuchMethodException e) {
+                Method create = nodeClass.getDeclaredMethod("create", ValueNode.class, ValueNode.class);
+                return (ValueNode) create.invoke(null, left, right);
+            }
         } catch (Throwable ex) {
             throw new GraalInternalError(ex).addContext(nodeClass.getName());
         }