Bug 100187 - [compiler] Code gen could be optimized
Summary: [compiler] Code gen could be optimized
Status: RESOLVED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2 M5   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-15 10:07 EDT by Olivier Thomann CLA
Modified: 2006-02-05 15: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 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 ?