Bug 7445

Summary: char/string concat bug
Product: [Eclipse Project] JDT Reporter: Olivier Thomann <Olivier_Thomann>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: salmasri
Version: 2.0   
Target Milestone: 2.0 M2   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Olivier Thomann CLA 2002-01-10 12:53:52 EST
From EC:

Reproduce with build 0109:

[public class Bug {
	public static void main(String[] args) {
		String s = "4";
		s = '0' + s;
		System.out.println( "test: " + s );
	}
}]

The output is:
test: 40

With javac 1.3, the output is:
test: 04

Need investigation why the concatenation is reversed.
Comment 1 Philipe Mulet CLA 2002-01-10 13:03:11 EST
This is a code gen optimization bug: s = '0' + s --> s += '0', but in the case 
of a String concat it is not allowed.
Comment 2 Philipe Mulet CLA 2002-01-10 14:01:59 EST
There was a fix in this area already, but the fix did only look at the left 
operand instead of both operands of the + expression to check for String...

Fixed.
Comment 3 Olivier Thomann CLA 2002-01-10 16:09:07 EST
Couldn't we check that the operation implicit conversion isn't T_String instead 
of checking the left and the right?


Comment 4 Philipe Mulet CLA 2002-02-07 13:22:55 EST
Backported to 1.0 stream (rollup2)
Comment 5 Olivier Thomann CLA 2002-02-07 16:19:47 EST
Verified and added test case (see ConformTest.test109).
Comment 6 Olivier Thomann CLA 2002-02-13 13:41:15 EST
Verified in rollup2.