svn commit: r526235 - in /jakarta/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals: Pass3bVerifier.java Subroutines.java

2007-04-06 Thread tcurdt
Author: tcurdt
Date: Fri Apr  6 10:41:12 2007
New Revision: 526235

URL: http://svn.apache.org/viewvc?view=revrev=526235
Log:
http://issues.apache.org/bugzilla/show_bug.cgi?id=40577


Modified:

jakarta/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java

jakarta/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/Subroutines.java

Modified: 
jakarta/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java
URL: 
http://svn.apache.org/viewvc/jakarta/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java?view=diffrev=526235r1=526234r2=526235
==
--- 
jakarta/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java
 (original)
+++ 
jakarta/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java
 Fri Apr  6 10:41:12 2007
@@ -23,13 +23,17 @@
 import java.util.List;
 import java.util.Random;
 import java.util.Vector;
+
 import org.apache.bcel.Constants;
 import org.apache.bcel.Repository;
 import org.apache.bcel.classfile.JavaClass;
 import org.apache.bcel.classfile.Method;
 import org.apache.bcel.generic.ConstantPoolGen;
+import org.apache.bcel.generic.GETFIELD;
 import org.apache.bcel.generic.InstructionHandle;
+import org.apache.bcel.generic.InvokeInstruction;
 import org.apache.bcel.generic.JsrInstruction;
+import org.apache.bcel.generic.LoadInstruction;
 import org.apache.bcel.generic.MethodGen;
 import org.apache.bcel.generic.ObjectType;
 import org.apache.bcel.generic.RET;
@@ -40,6 +44,7 @@
 import org.apache.bcel.verifier.VerificationResult;
 import org.apache.bcel.verifier.Verifier;
 import org.apache.bcel.verifier.exc.AssertionViolatedException;
+import org.apache.bcel.verifier.exc.StructuralCodeConstraintException;
 import org.apache.bcel.verifier.exc.VerifierConstraintViolatedException;
 
 /**
@@ -126,7 +131,7 @@
* The proof of termination is about the existence of a
* fix point of frame merging.
 */
-   private void circulationPump(ControlFlowGraph cfg, InstructionContext 
start, Frame vanillaFrame, InstConstraintVisitor icv, ExecutionVisitor ev){
+   private void circulationPump(MethodGen m,ControlFlowGraph cfg, 
InstructionContext start, Frame vanillaFrame, InstConstraintVisitor icv, 
ExecutionVisitor ev){
final Random random = new Random();
InstructionContextQueue icq = new InstructionContextQueue();

@@ -246,6 +251,44 @@
this.addMessage(Warning: 
ReturnInstruction '+ic+' may leave method with an uninitialized object on the 
operand stack '+os+'.);
}
}
+//see JVM $4.8.2
+//TODO implement all based on stack 
+Type returnedType = null;
+if( ih.getPrev().getInstruction() instanceof InvokeInstruction 
)
+{
+returnedType = 
((InvokeInstruction)ih.getPrev().getInstruction()).getType(m.getConstantPool());
+}
+if( ih.getPrev().getInstruction() instanceof LoadInstruction )
+{
+int index = 
((LoadInstruction)ih.getPrev().getInstruction()).getIndex();
+returnedType = lvs.get(index);
+}
+if( ih.getPrev().getInstruction() instanceof GETFIELD )
+{
+returnedType = 
((GETFIELD)ih.getPrev().getInstruction()).getType(m.getConstantPool());
+}
+if( returnedType != null )
+{
+if( returnedType instanceof ObjectType )
+{
+try
+{
+if( 
!((ObjectType)returnedType).isAssignmentCompatibleWith(m.getReturnType()) )
+{
+throw new 
StructuralCodeConstraintException(Returned type +returnedType+ does not 
match Method's return type +m.getReturnType());
+}
+}
+catch (ClassNotFoundException e)
+{
+//dont know what do do now, so raise 
RuntimeException
+throw new RuntimeException(e);
+}
+}
+else if( !returnedType.equals(m.getReturnType()) )
+{
+throw new StructuralCodeConstraintException(Returned 
type +returnedType+ does not match Method's return type +m.getReturnType());
+}
+}
}
}while ((ih = ih.getNext()) != null);

@@ -321,7 +364,7 @@

DO NOT REPLY [Bug 42015] - Verifier fails in pass 2 with Number of LocalVariableTable attributes of Code attribute on static methods.

2007-04-06 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
http://issues.apache.org/bugzilla/show_bug.cgi?id=42015.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42015


[EMAIL PROTECTED] changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED




--- Additional Comments From [EMAIL PROTECTED]  2007-04-06 10:44 ---
Thanks! Applied!

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug, or are watching the assignee.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]