Bug 244477 - [formatter] Formatter fails on special Java array construct
Summary: [formatter] Formatter fails on special Java array construct
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M2   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-08-18 16:48 EDT by phloc CLA
Modified: 2008-09-15 09:28 EDT (History)
3 users (show)

See Also:


Attachments
Proposed fix + regression tests (8.92 KB, patch)
2008-08-18 20:59 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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