Community
Participate
Working Groups
Go to Windows > Preferences > Java > Code Style > Formatter and edit the formatter profile. In the 'Indentation' tab, change Tab policy to 'Spaces only' and set Indentation size to '0': !MESSAGE The formatter threw an unhandled exception while formatting the preview. !STACK 0 java.lang.ArithmeticException: / by zero at org.eclipse.jdt.internal.formatter.Scribe.setIndentation(Scribe.java:1510) at org.eclipse.jdt.internal.formatter.CodeFormatterVisitor.visit(CodeFormatterVisitor.java:5496) at org.eclipse.jdt.internal.compiler.ast.SwitchStatement.traverse(SwitchStatement.java:610) at org.eclipse.jdt.internal.formatter.CodeFormatterVisitor.formatStatements(CodeFormatterVisitor.java:2108) at org.eclipse.jdt.internal.formatter.CodeFormatterVisitor.visit(CodeFormatterVisitor.java:4683) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse(MethodDeclaration.java:317) at org.eclipse.jdt.internal.formatter.CodeFormatterVisitor.format(CodeFormatterVisitor.java:615) at org.eclipse.jdt.internal.formatter.CodeFormatterVisitor.formatTypeMembers(CodeFormatterVisitor.java:2275) at org.eclipse.jdt.internal.formatter.CodeFormatterVisitor.format(CodeFormatterVisitor.java:1258) at org.eclipse.jdt.internal.formatter.CodeFormatterVisitor.visit(CodeFormatterVisitor.java:5805) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1338) at org.eclipse.jdt.internal.formatter.CodeFormatterVisitor.visit(CodeFormatterVisitor.java:3440) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse(CompilationUnitDeclaration.java:712) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse(CompilationUnitDeclaration.java:706) at org.eclipse.jdt.internal.formatter.CodeFormatterVisitor.format(CodeFormatterVisitor.java:904) at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.formatCompilationUnit(DefaultCodeFormatter.java:244) at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.format(DefaultCodeFormatter.java:166) at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.format(DefaultCodeFormatter.java:149) at org.eclipse.jdt.internal.corext.util.CodeFormatterUtil.reformat(CodeFormatterUtil.java:288) at org.eclipse.jdt.internal.ui.text.java.JavaFormattingStrategy.format(JavaFormattingStrategy.java:67) at org.eclipse.jface.text.formatter.MultiPassContentFormatter.formatMaster(MultiPassContentFormatter.java:193) at org.eclipse.jface.text.formatter.MultiPassContentFormatter.format(MultiPassContentFormatter.java:142) at org.eclipse.jdt.internal.ui.preferences.formatter.CompilationUnitPreview.doFormatPreview(CompilationUnitPreview.java:61) at org.eclipse.jdt.internal.ui.preferences.formatter.JavaPreview.update(JavaPreview.java:174) at org.eclipse.jdt.internal.ui.preferences.formatter.IndentationTabPage.doUpdatePreview(IndentationTabPage.java:141) at org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialogTabPage$1.update(ModifyDialogTabPage.java:71) at java.util.Observable.notifyObservers(Observable.java:159) at java.util.Observable.notifyObservers(Observable.java:115) at org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialogTabPage$NumberPreference.saveSelected(ModifyDialogTabPage.java:434) at org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialogTabPage$NumberPreference.focusLost(ModifyDialogTabPage.java:396) at org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialogTabPage$NumberPreference$1.focusLost(ModifyDialogTabPage.java:367) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:143)
This problem no longer occurs after the formatter redesign. *** This bug has been marked as a duplicate of bug 303519 ***