comparison graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java @ 9307:1e1d619487b9

Additional assertions to guard against calls to abstract methods.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Thu, 25 Apr 2013 17:42:55 +0200
parents 149092d59dd0
children ef6915cf1e59
comparison
equal deleted inserted replaced
9291:90ee20fd2c05 9307:1e1d619487b9
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any 20 * or visit www.oracle.com if you need additional information or have any
21 * questions. 21 * questions.
22 */ 22 */
23 package com.oracle.graal.nodes.java; 23 package com.oracle.graal.nodes.java;
24
25 import java.lang.reflect.*;
24 26
25 import com.oracle.graal.api.meta.*; 27 import com.oracle.graal.api.meta.*;
26 import com.oracle.graal.graph.*; 28 import com.oracle.graal.graph.*;
27 import com.oracle.graal.nodes.*; 29 import com.oracle.graal.nodes.*;
28 import com.oracle.graal.nodes.spi.*; 30 import com.oracle.graal.nodes.spi.*;
100 public boolean verify() { 102 public boolean verify() {
101 assert usages().count() <= 1 : "call target may only be used by a single invoke"; 103 assert usages().count() <= 1 : "call target may only be used by a single invoke";
102 for (Node n : usages()) { 104 for (Node n : usages()) {
103 assertTrue(n instanceof Invoke, "call target can only be used from an invoke (%s)", n); 105 assertTrue(n instanceof Invoke, "call target can only be used from an invoke (%s)", n);
104 } 106 }
107 if (invokeKind == InvokeKind.Special || invokeKind == InvokeKind.Static) {
108 assertFalse(Modifier.isAbstract(targetMethod.getModifiers()), "special calls or static calls are only allowed for concrete methods (%s)", targetMethod);
109 }
110 if (invokeKind == InvokeKind.Static) {
111 assertTrue(Modifier.isStatic(targetMethod.getModifiers()), "static calls are only allowed for static methods (%s)", targetMethod);
112 } else {
113 assertFalse(Modifier.isStatic(targetMethod.getModifiers()), "static calls are only allowed for non-static methods (%s)", targetMethod);
114 }
105 return super.verify(); 115 return super.verify();
106 } 116 }
107 117
108 @Override 118 @Override
109 public String toString(Verbosity verbosity) { 119 public String toString(Verbosity verbosity) {