Bug 5498 - Java Compile - code does not compile correctly in JDT, but does with javac
Summary: Java Compile - code does not compile correctly in JDT, but does with javac
Status: RESOLVED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 1.0   Edit
Hardware: PC Windows 2000
: P2 major (vote)
Target Milestone: 2.0 M1   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-11-02 15:44 EST by Paula Cox (WSAD) CLA
Modified: 2002-01-11 09:22 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 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