Bug 244477

Summary: [formatter] Formatter fails on special Java array construct
Product: [Eclipse Project] JDT Reporter: phloc <office>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: frederic_fusier, jerome_lanneluc, Olivier_Thomann
Version: 3.4   
Target Milestone: 3.5 M2   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed fix + regression tests none

Description phloc CLA 2008-08-18 16:48:36 EDT
Build ID: I20080617-2000

Steps To Reproduce:
1. create a file that contains a construct like "final String [] empty = new String[] {,};"
2. Try to format the file (either Shift+Strg+F or Cleanup or...)
3. Nothing happens.

If the line is replaced with "final String [] empty = new String[0];" everything works as expected


More information:
Comment 1 Olivier Thomann CLA 2008-08-18 17:43:36 EDT
Fix is trivial.
Comment 2 Olivier Thomann CLA 2008-08-18 20:59:36 EDT
Created attachment 110305 [details]
Proposed fix + regression tests

Jérôme, since the formatter fails, I think this might be a good candidate for 3.4.1.
Comment 3 Olivier Thomann CLA 2008-08-18 21:00:46 EDT
Released for 3.5M2.
Regression tests added in org.eclipse.jdt.core.tests.formatter.FormatterRegressionTests#test715
org.eclipse.jdt.core.tests.formatter.FormatterRegressionTests#test716
org.eclipse.jdt.core.tests.formatter.FormatterRegressionTests#test717
org.eclipse.jdt.core.tests.formatter.FormatterRegressionTests#test718
Comment 4 Jerome Lanneluc CLA 2008-08-19 12:33:10 EDT
Is this a regression comparing to 3.3.2?
Comment 5 Olivier Thomann CLA 2008-08-19 12:45:07 EDT
I don't think so, but it is a crash in the formatter. The unit that contains such piece of code cannot be formatted.
Since the fix is trivial, I think it is a good idea for a maintenance release.
Comment 6 Jerome Lanneluc CLA 2008-08-20 04:55:18 EDT
The description of this bug doesn't talk about a crash. Since this is not a regression, it cannot go in 3.4.1.
Comment 7 Frederic Fusier CLA 2008-08-20 09:03:26 EDT
(In reply to comment #6)
> The description of this bug doesn't talk about a crash. Since this is not a
> regression, it cannot go in 3.4.1.
> 
I confirm that 3.3.2 already has the same issue
Comment 8 Olivier Thomann CLA 2008-08-20 09:43:11 EDT
(In reply to comment #6)
> The description of this bug doesn't talk about a crash. Since this is not a
> regression, it cannot go in 3.4.1.
When the contents of the compilation unit is not modified after a formatting operation, it means that the code formatter failed. This affects the whole unit and there is no way for the user to know what caused the failure in the formatter.
Comment 9 Jerome Lanneluc CLA 2008-09-15 09:28:05 EDT
Verified for 3.5M2 using I20080914-2000