You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bcel-dev@jakarta.apache.org by en...@apache.org on 2003/12/18 19:58:24 UTC
cvs commit: jakarta-bcel/src/java/org/apache/bcel/verifier/structurals InstConstraintVisitor.java
enver 2003/12/18 10:58:24
Modified: src/java/org/apache/bcel/verifier/structurals
InstConstraintVisitor.java
Log:
RETURN must only be used in VOID methods.
Revision Changes Path
1.8 +16 -10 jakarta-bcel/src/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java
Index: InstConstraintVisitor.java
===================================================================
RCS file: /home/cvs/jakarta-bcel/src/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- InstConstraintVisitor.java 20 Aug 2003 13:31:14 -0000 1.7
+++ InstConstraintVisitor.java 18 Dec 2003 18:58:24 -0000 1.8
@@ -418,8 +418,21 @@
* Assures the generic preconditions of a ReturnInstruction instance.
*/
public void visitReturnInstruction(ReturnInstruction o){
- if (o instanceof RETURN){
- return;
+ Type method_type = mg.getType();
+ if (method_type == Type.BOOLEAN ||
+ method_type == Type.BYTE ||
+ method_type == Type.SHORT ||
+ method_type == Type.CHAR){
+ method_type = Type.INT;
+ }
+
+ if (o instanceof RETURN){
+ if (method_type != Type.VOID){
+ constraintViolated(o, "RETURN instruction in non-void method.");
+ }
+ else{
+ return;
+ }
}
if (o instanceof ARETURN){
if (stack().peek() == Type.NULL){
@@ -439,13 +452,6 @@
}
}
else{
- Type method_type = mg.getType();
- if (method_type == Type.BOOLEAN ||
- method_type == Type.BYTE ||
- method_type == Type.SHORT ||
- method_type == Type.CHAR){
- method_type = Type.INT;
- }
if (! ( method_type.equals( stack().peek() ))){
constraintViolated(o, "Current method has return type of '"+mg.getType()+"' expecting a '"+method_type+"' on top of the stack. But stack top is a '"+stack().peek()+"'.");
}
---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-dev-help@jakarta.apache.org