You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by km...@apache.org on 2007/05/07 20:37:50 UTC

svn commit: r535949 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/Conditional.java

Author: kmarsden
Date: Mon May  7 11:37:48 2007
New Revision: 535949

URL: http://svn.apache.org/viewvc?view=rev&rev=535949
Log:
DERBY-2230 AssertFailure: ByteCode Conditional then/else stack mismatch
The compiler/bytecode generator code does not load classes to check relationships or any other information. This is making things difficult to fix this bug. Also, I think it is not worth to go this way for a simple check that too in a DEBUG block.

Check for non-matching return types of then and else blocks in Conditional statement is made during bindExpression call and 42X89 is thrown if false. Hence, During byte code generation, check for non-matching return types is not required. I believe the assert check was included just to make sure that the stacks are consistent. But, it seems they do not consider a valid case where the two return types can have different vmNames (StringValue, ConcatableDataValue) which are assignable.

I have created a patch that works around this problem by adding another check for vmTypes. One of the reasons I chose vmType is because I saw BCMethod making its casting decision based on vmType. 

Contributed by Mayuresh Nirhali (Mayuresh.Nirhali@Sun.COM)



Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/Conditional.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/Conditional.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/Conditional.java?view=diff&rev=535949&r1=535948&r2=535949
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/Conditional.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/Conditional.java Mon May  7 11:37:48 2007
@@ -212,10 +212,12 @@
 			
 			for (int i = 0; i < stackNumber; i++)
 			{
-				if (!stack[i].vmName().equals(elseStack[i].vmName()))
+				if (stack[i].vmType() != elseStack[i].vmType()) {
+				    if(  !stack[i].vmName().equals(elseStack[i].vmName()))
 					SanityManager.THROWASSERT("ByteCode Conditional then/else stack mismatch: then: "
 							+ stack[i].vmName() + 
 							" else: " + elseStack[i].vmName());
+				}
 			}
 		}