Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 275360 - [toString] Wrong code generated with String concatenation
Summary: [toString] Wrong code generated with String concatenation
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.5   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.5 RC1   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-07 15:15 EDT by Mateusz Matela CLA
Modified: 2009-05-15 05:50 EDT (History)
2 users (show)

See Also:
daniel_megert: review+


Attachments
fix (25.36 KB, patch)
2009-05-07 15:20 EDT, Mateusz Matela CLA
daniel_megert: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mateusz Matela CLA 2009-05-07 15:15:49 EDT
When String concatenation style is used, wrong code is generated, for example:

public class A {
	String ss[];

	@Override
	public String toString() {
		final int maxLen = 10;
		return "A [ss=" + ss != null ? Arrays.asList(ss).subList(0,
				Math.min(ss.length, maxLen)) : null + "]";
	}
}

The "ss != null ? .. : null" fragments should be enclosed in parenthesis, otherwise there's a compilation error or unexpected behavior.
Comment 1 Mateusz Matela CLA 2009-05-07 15:20:42 EDT
Created attachment 134850 [details]
fix
Comment 2 Dani Megert CLA 2009-05-11 05:02:59 EDT
Looks fixed to me in I200908-2000.
Comment 3 Markus Keller CLA 2009-05-11 05:33:58 EDT
Missing steps in comment 0:
- uncheck "Skip null values"
- check the other two boxes

Dani, can you please review the fix? OK to release from my side.
Comment 4 Dani Megert CLA 2009-05-11 06:18:56 EDT
Committed to HEAD with updated copyright date and added bug URL.
Available in builds >= I20090511-2000.
Comment 5 Dani Megert CLA 2009-05-15 05:50:18 EDT
Verified in I20090514-2000.