Bug 293496 - Adding the serialVersionUID field doesn't work when tab size is 0
Summary: Adding the serialVersionUID field doesn't work when tab size is 0
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.6   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.6 M3   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-27 15:28 EDT by Olivier Thomann CLA
Modified: 2009-10-30 09:20 EDT (History)
1 user (show)

See Also:


Attachments
Proposed fix (2.17 KB, patch)
2009-10-27 15:30 EDT, Olivier Thomann CLA
no flags Details | Diff
Proposed fix + regression test (3.94 KB, patch)
2009-10-27 17:03 EDT, Olivier Thomann CLA
no flags Details | Diff
Released patch (76.60 KB, patch)
2009-10-28 06:17 EDT, Frederic Fusier CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2009-10-27 15:28:26 EDT
Using I20091027-0100,
1) Create a new project and set the formatter options to use a 0 size for tab length
2) Set the mode to be mixed mode for tabs and spaces
3) Create a class that implements java.io.Serializable, but don't add the serialVersionUID field
4) Try to use the quick fix to add the field.
5) You should get an error.
Caused by: java.lang.ArithmeticException: / by zero
at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.createIndentationString(DefaultCodeFormatter.java:144)
at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteFormatter.createIndentString(ASTRewriteFormatter.java:196)
at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.createIndentString(ASTRewriteAnalyzer.java:278)
at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer$ParagraphListRewriter.getSeparatorString(ASTRewriteAnalyzer.java:878)
at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer$ParagraphListRewriter.getSeparatorString(ASTRewriteAnalyzer.java:867)
at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer$ListRewriter.rewriteList(ASTRewriteAnalyzer.java:574)
at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.rewriteParagraphList(ASTRewriteAnalyzer.java:997)
at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.visit(ASTRewriteAnalyzer.java:1575)
at org.eclipse.jdt.core.dom.TypeDeclaration.accept0(TypeDeclaration.java:467)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2480)
at org.eclipse.jdt.core.dom.rewrite.ASTRewrite.internalRewriteAST(ASTRewrite.java:271)
at org.eclipse.jdt.core.dom.rewrite.ASTRewrite.rewriteAST(ASTRewrite.java:260)
at org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite.attachChange(CompilationUnitRewrite.java:248)
at org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite.createChange(CompilationUnitRewrite.java:213)
at org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFix.createChange(CompilationUnitRewriteOperationsFix.java:103)
at org.eclipse.jdt.internal.ui.text.correction.proposals.FixCorrectionProposal.createTextChange(FixCorrectionProposal.java:155)
at org.eclipse.jdt.internal.ui.text.correction.proposals.CUCorrectionProposal.createChange(CUCorrectionProposal.java:389)
at org.eclipse.jdt.internal.ui.text.correction.proposals.ChangeCorrectionProposal.getChange(ChangeCorrectionProposal.java:301)
at org.eclipse.jdt.internal.ui.text.correction.proposals.ChangeCorrectionProposal.performChange(ChangeCorrectionProposal.java:119)
at org.eclipse.jdt.internal.ui.text.correction.proposals.CUCorrectionProposal.performChange(CUCorrectionProposal.java:323)
at org.eclipse.jdt.internal.ui.text.correction.proposals.CUCorrectionProposal.apply(CUCorrectionProposal.java:301)
at org.eclipse.jdt.internal.ui.text.correction.CorrectionMarkerResolutionGenerator$CorrectionMarkerResolution.run(CorrectionMarkerResolutionGenerator.java:117)
at org.eclipse.jdt.internal.ui.text.correction.CorrectionMarkerResolutionGenerator$CorrectionMarkerResolution.run(CorrectionMarkerResolutionGenerator.java:130)
at org.eclipse.ui.internal.views.markers.QuickFixPage$11.run(QuickFixPage.java:560)
at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:464)
Comment 1 Olivier Thomann CLA 2009-10-27 15:30:16 EDT
Created attachment 150670 [details]
Proposed fix
Comment 2 Olivier Thomann CLA 2009-10-27 17:03:15 EDT
Created attachment 150686 [details]
Proposed fix + regression test

Same patch with a regression test.
Comment 3 Frederic Fusier CLA 2009-10-28 06:11:51 EDT
(In reply to comment #2)
> Created an attachment (id=150686) [details]
> Proposed fix + regression test
> 
> Same patch with a regression test.

Patch looks good. I'll just move the test to FormatterBugTests test suite instead as there's no data used from the test 'Formatter' workspace, hence there's no need to initialize this workspace while running the test...
Comment 4 Frederic Fusier CLA 2009-10-28 06:17:51 EDT
Created attachment 150711 [details]
Released patch

This patch is the same fix than Olivier's patch with the test moved to the FormatterBugTests test suite.
Comment 5 Frederic Fusier CLA 2009-10-28 06:18:43 EDT
(In reply to comment #4)
> Created an attachment (id=150711) [details]
> Released patch
> 
Released for 3.6M3 in HEAD stream.
Comment 6 Olivier Thomann CLA 2009-10-30 09:20:57 EDT
Verified for 3.6M3 using I20091029-0840.