Bug 6596 - Java compiler can generate invalid bytecode
Summary: Java compiler can generate invalid bytecode
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P1 major (vote)
Target Milestone: 2.0 M1   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-12-05 11:18 EST by paulm CLA
Modified: 2001-12-05 17:46 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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)