Bug 6596

Summary: Java compiler can generate invalid bytecode
Product: [Eclipse Project] JDT Reporter: paulm
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P1    
Version: 2.0   
Target Milestone: 2.0 M1   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description paulm CLA 2001-12-05 11:18:53 EST
I stumbled across this bug in eclipse-SDK-20011107-win32 compiling an existing 
java project and I worked it down to this test case:

public class Test {
    public static void main(String[] args) {
        System.out.println("hello");
    }
    
    public void testcase() {
        boolean a = false;
        boolean b = false;

        if (!(a && b)) {}
    }
}

With Sun's java compiler the program outputs:
hello

Although Eclipse will compile this when you run it you get:
Exception in thread "main" java.lang.VerifyError: (class: Test, method: testcase
 signature: ()V) Inconsistent stack height 0 != 1

I would consider this a serious bug as code compiled with Eclipse could give 
this error after it has been deployed.
Comment 1 Philipe Mulet CLA 2001-12-05 16:45:49 EST
Seems like a bug in boolean optimization.
Comment 2 Philipe Mulet CLA 2001-12-05 17:34:09 EST
Bug isolated. When optimizing the ! operator code gen, we forgot to place the 
falseLabel (leaving it to its current value).

Note that our codegen is slightly more compact than javac 1.4.
Comment 3 Philipe Mulet CLA 2001-12-05 17:46:39 EST
This was an excellent find, thanks.

Fixed (for next tuesday integration build)