Bug 238538 - AIOOBE while formatting code
Summary: AIOOBE while formatting code
Status: VERIFIED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M1   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-06-26 05:24 EDT by Krzysztof Daniel CLA
Modified: 2008-08-13 05:17 EDT (History)
4 users (show)

See Also:


Attachments
TestCase (67 bytes, text/plain)
2008-06-26 05:24 EDT, Krzysztof Daniel CLA
no flags Details
Workaround (1.09 KB, patch)
2008-07-02 09:10 EDT, Krzysztof Daniel CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Krzysztof Daniel CLA 2008-06-26 05:24:06 EDT
Created attachment 105867 [details]
TestCase

Build ID:  M20070212-1330

Steps To Reproduce:
1. Import attached file.
2. Ctrl + Shift + F
3. Observe the .log


More information:
This is caused by <pre>&#x20;</pre> in the javadoc code. Formatter is rather basic functionality...
Comment 1 Markus Keller CLA 2008-06-26 06:14:34 EDT
Please set the correct version when you file a bug against a historic release. Reproduced in 3.2.2.

Does not throw an exception in 3.3.2 and later, but converts &#x20; into a space. 
Filed bug 238547 for the unexpected conversion of HTML entities.
Comment 2 Krzysztof Daniel CLA 2008-07-02 09:10:49 EDT
Created attachment 106308 [details]
Workaround

This is not a solution, only workaround. I have made a small investigation and it seems to me that scanner replaces &x20; with space, and then ignores the space and looks for the nonblank character.

There is a couple of facts confirming this hyphothesis:
* parser works perfectly for non blank characters
* parser works perfectly if there is any non blank character after &x20;

Markus,
are you able now to give me any hints now? And also, do you think that it could be possible to mark this bug as opened, or wontfix?
Comment 3 Dani Megert CLA 2008-07-02 09:18:21 EDT
The previous comment probably belongs to bug 238547. Or are you still claiming to get the AIOOBE?
Comment 4 Dani Megert CLA 2008-07-02 09:39:53 EDT
Reopen to move to right component.
Comment 5 Dani Megert CLA 2008-07-02 09:40:37 EDT
Here's the stack trace:

java.lang.ArrayIndexOutOfBoundsException
at java.lang.System.arraycopy(Native Method)
at org.eclipse.jdt.internal.compiler.parser.Scanner.getCurrentTokenSource(Scanner.java:428)
at org.eclipse.jdt.internal.formatter.Scribe.printComment(Scribe.java:858)
at org.eclipse.jdt.internal.formatter.CodeFormatterVisitor.visit(CodeFormatterVisitor.java:2919)
at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse(CompilationUnitDeclaration.java:474)
at org.eclipse.jdt.internal.formatter.CodeFormatterVisitor.format(CodeFormatterVisitor.java:756)
at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.formatCompilationUnit(DefaultCodeFormatter.java:251)
at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.probeFormatting(DefaultCodeFormatter.java:551)
at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.format(DefaultCodeFormatter.java:166)
at org.eclipse.jdt.internal.formatter.comment.CommentFormatterUtil.format2(CommentFormatterUtil.java:71)
at org.eclipse.jdt.internal.formatter.comment.JavaDocRegion.formatCodeSnippet(JavaDocRegion.java:182)
at org.eclipse.jdt.internal.formatter.comment.JavaDocRegion.formatRegion(JavaDocRegion.java:129)
at org.eclipse.jdt.internal.formatter.comment.CommentRegion.format(CommentRegion.java:187)
at org.eclipse.jdt.internal.formatter.CodeFormatterVisitor.format(CodeFormatterVisitor.java:860)
at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.formatComment(DefaultCodeFormatter.java:215)
at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.format(DefaultCodeFormatter.java:170)
at org.eclipse.jdt.internal.ui.text.comment.CommentFormattingStrategy.format(CommentFormattingStrategy.java:92)
at org.eclipse.jface.text.formatter.MultiPassContentFormatter.formatSlave(MultiPassContentFormatter.java:220)
at org.eclipse.jface.text.formatter.MultiPassContentFormatter.formatSlaves(MultiPassContentFormatter.java:267)
at org.eclipse.jface.text.formatter.MultiPassContentFormatter.format(MultiPassContentFormatter.java:143)
at org.eclipse.jface.text.source.SourceViewer.doOperation(SourceViewer.java:822)
at org.eclipse.jface.text.source.projection.ProjectionViewer.doOperation(ProjectionViewer.java:1519)
at org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer.doOperation(JavaSourceViewer.java:178)
at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewer.doOperation(CompilationUnitEditor.java:201)
at org.eclipse.ui.texteditor.TextOperationAction$1.run(TextOperationAction.java:131)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
at org.eclipse.ui.texteditor.TextOperationAction.run(TextOperationAction.java:129)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:499)
at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:185)
at org.eclipse.ui.internal.handlers.LegacyHandlerWrapper.execute(LegacyHandlerWrapper.java:109)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:461)
at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:424)
at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:160)
at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:466)
at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:799)
at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:846)
at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:564)
at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:506)
at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:122)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Display.filterEvent(Display.java:982)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:927)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:952)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:937)
at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:965)
at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:961)
at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1275)
at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3346)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3246)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4025)
at org.eclipse.swt.internal.win32.OS.CallWindowProcW(Native Method)
at org.eclipse.swt.internal.win32.OS.CallWindowProc(OS.java:1851)
at org.eclipse.swt.internal.BidiUtil.windowProc(BidiUtil.java:649)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1932)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2966)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1930)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1894)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:422)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:95)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336)
at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
at org.eclipse.core.launcher.Main.run(Main.java:977)
at org.eclipse.core.launcher.Main.main(Main.java:952)
Comment 6 Dani Megert CLA 2008-07-02 09:44:57 EDT
Marking as fixed in 3.3 (could not find a corresponding JDT Core bug).
Comment 7 Olivier Thomann CLA 2008-08-06 12:21:06 EDT
Verified for 3.5M1 using I20080805-1307.
No crash anymore.
Resulting formatted code is:
/**
 * <pre>
 * 
 * </pre>
 */
public class TestClass {

}
Comment 8 Jerome Lanneluc CLA 2008-08-13 05:17:07 EDT
Changing resolution to WORKSFORME as no action was taken to fix this bug.