Bug 222182 - [formatter] AIOOB in Util.getLineNumber(Util.java:438)
Summary: [formatter] AIOOB in Util.getLineNumber(Util.java:438)
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: 3.4 M6   Edit
Assignee: Eric Jodet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-11 04:32 EDT by Dani Megert CLA
Modified: 2008-03-25 12:57 EDT (History)
1 user (show)

See Also:


Attachments
Formatter prefs (28.12 KB, text/xml)
2008-03-11 04:35 EDT, Dani Megert CLA
no flags Details
[patch] - proposed fix + test case (31.98 KB, patch)
2008-03-11 10:09 EDT, Eric Jodet CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2008-03-11 04:32:22 EDT
HEAD (today's plug-in export of JDT Core).

1. import attached formatter profile
2. paste this into Package Explorer:
package pack;

public class Test {
    /**
	 * @see Test.Inner
	 */
    public class Inner { }
}

3. select the line "    public class Inner { }"
4. Format (Ctrl+Shift+F)
==> AIOOB
java.lang.ArrayIndexOutOfBoundsException: 8
	at org.eclipse.jdt.internal.compiler.util.Util.getLineNumber(Util.java:438)
	at org.eclipse.jdt.internal.formatter.Scribe.isAdaptableRegion(Scribe.java:765)
	at org.eclipse.jdt.internal.formatter.Scribe.adaptRegions(Scribe.java:127)
	at org.eclipse.jdt.internal.formatter.Scribe.getRootEdit(Scribe.java:634)
	at org.eclipse.jdt.internal.formatter.CodeFormatterVisitor.format(CodeFormatterVisitor.java:806)
	at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.formatCompilationUnit(DefaultCodeFormatter.java:297)
	at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.format(DefaultCodeFormatter.java:176)
	at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.format(DefaultCodeFormatter.java:160)
	at org.eclipse.jdt.internal.corext.util.CodeFormatterUtil.reformat(CodeFormatterUtil.java:288)
	at org.eclipse.jdt.internal.ui.text.java.JavaFormattingStrategy.format(JavaFormattingStrategy.java:64)
	at org.eclipse.jface.text.formatter.MultiPassContentFormatter.formatMaster(MultiPassContentFormatter.java:193)
	at org.eclipse.jface.text.formatter.MultiPassContentFormatter.format(MultiPassContentFormatter.java:135)
	at org.eclipse.jface.text.source.SourceViewer.doOperation(SourceViewer.java:836)
	at org.eclipse.jface.text.source.projection.ProjectionViewer.doOperation(ProjectionViewer.java:1507)
	at org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer.doOperation(JavaSourceViewer.java:178)
	at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewer.doOperation(CompilationUnitEditor.java:195)
	at org.eclipse.ui.texteditor.TextOperationAction$1.run(TextOperationAction.java:131)
...
Comment 1 Dani Megert CLA 2008-03-11 04:35:03 EDT
Marking as major because I format the changed lines on save and now it booms when I want to save this file.
Comment 2 Dani Megert CLA 2008-03-11 04:35:55 EDT
Created attachment 92135 [details]
Formatter prefs
Comment 3 Dani Megert CLA 2008-03-11 04:36:37 EDT
See also bug 213283 which claims to have fixed an AIOOBE.
Comment 4 Eric Jodet CLA 2008-03-11 10:09:23 EDT
Created attachment 92164 [details]
[patch] - proposed fix + test case

side effect of fix for bug 208541 released in 3.4 M4.

This fix passes all jdt.core, UI and text tests
Comment 5 Eric Jodet CLA 2008-03-12 09:46:58 EDT
Patch released for 3.4M6 in HEAD.
Comment 6 Kent Johnson CLA 2008-03-25 12:57:33 EDT
Verified for 3.4M6 using build I20080324-1300