Bug 5498

Summary: Java Compile - code does not compile correctly in JDT, but does with javac
Product: [Eclipse Project] JDT Reporter: Paula Cox (WSAD) <paulacox>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: RESOLVED WORKSFORME QA Contact:
Severity: major    
Priority: P2    
Version: 1.0   
Target Milestone: 2.0 M1   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Paula Cox (WSAD) CLA 2001-11-02 15:44:20 EST
It seems as though there is a bug in the compiler. The                 
following code does not compile correctly...                            
                                                                       
public void test() {                                                    
Object obj = "test";                                                  
  obj = obj + "ing";                                                    
  System.out.println(obj);                                              
}                                                                       
                                                                        
This produces the following output: "ing"                               
However this code works...                                              
                                                                        
public void test() {                                                    
  Object obj = "test";                                                  
  obj = (String)obj + "ing";                                            
  System.out.println(obj);                                              
}                                                                       
                                                                        
Thus producing the output: "testing"                                    
                                                                        
I noticed that when I compile this under Sun's "javac",                 
it works fine. And when I looked at the PCODE that was                 
produced, it was definitely wrong.

<188674>
Comment 1 Philipe Mulet CLA 2001-11-02 17:25:47 EST
Known defect which was corrected in 2.0 stream. Bug in code optimization of 
String concatenation (Object = Object + String --> Object += String).

Closing
Comment 2 Philipe Mulet CLA 2001-11-02 17:31:01 EST
Closing
Comment 3 Jerome Lanneluc CLA 2001-12-05 06:30:53 EST
Fixed in 1.0 Rollup 139