Bug 100187

Summary: [compiler] Code gen could be optimized
Product: [Eclipse Project] JDT Reporter: Olivier Thomann <Olivier_Thomann>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1   
Target Milestone: 3.2 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Olivier Thomann CLA 2005-06-15 10:07:12 EDT
Test case:

public class TestBug {
    final boolean isA = true;
    
    public static void main(String[] args) {        
        TestBug test = new TestBug();        
        System.out.println(test.isA ? "A" : "B");
    }
}

Following bug 100162, the code gen for this test case to be optimized.

We should generate the null check and then inline the true/false expression
according to the constant value.
Comment 1 Philipe Mulet CLA 2006-02-05 15:46:11 EST
Our latest 3.2 build issues:
  public static void main(String[] args);
     0  new X [1]
     3  dup
     4  invokespecial X() [22]
     7  astore_1 [test]
     8  getstatic System.out : PrintStream [23]
    11  aload_1 [test]
    12  invokevirtual Object.getClass() : Class [29]
    15  pop
    16  ldc <String "A"> [33]
    18  invokevirtual PrintStream.println(String) : void [35]
    21  return

This is likely a consequence of our boolean codegen optimization earlier in 3.2 stream.

Olivier - could you pls add a testcase validating the codegen output ?