Bug 304529 - [formatter] NPE when either the disabling or the enabling tag is not defined
Summary: [formatter] NPE when either the disabling or the enabling tag is not defined
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.6   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.6 M6   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-03 10:50 EST by Markus Keller CLA
Modified: 2010-03-09 16:19 EST (History)
2 users (show)

See Also:


Attachments
Proposed patch (5.16 KB, patch)
2010-03-03 11:30 EST, 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 Markus Keller CLA 2010-03-03 10:50:15 EST
HEAD with fix for bug 27079.

- Set these formatter options:

org.eclipse.jdt.core.formatter.disabling_tag=off
org.eclipse.jdt.core.formatter.enabling_tag=

- Try to format a CU
=>NPE:

!ENTRY org.eclipse.ui 4 4 2010-03-03 16:48:35.282
!MESSAGE "Format" did not complete normally.  Please see the log for more information.

!ENTRY org.eclipse.ui 4 0 2010-03-03 16:48:35.298
!MESSAGE java.lang.NullPointerException
!STACK 0
java.lang.NullPointerException
	at org.eclipse.jdt.core.compiler.CharOperation.compareTo(CharOperation.java:748)
	at org.eclipse.jdt.internal.compiler.util.Util.reverseQuickSort(Util.java:675)
	at org.eclipse.jdt.internal.compiler.parser.Scanner.<init>(Scanner.java:227)
	at org.eclipse.jdt.internal.compiler.parser.Scanner.<init>(Scanner.java:251)
	at org.eclipse.jdt.internal.formatter.Scribe.initializeScanner(Scribe.java:1306)
	at org.eclipse.jdt.internal.formatter.Scribe.<init>(Scribe.java:142)
	at org.eclipse.jdt.internal.formatter.CodeFormatterVisitor.<init>(CodeFormatterVisitor.java:185)
	at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.formatCompilationUnit(DefaultCodeFormatter.java:239)
	at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.format(DefaultCodeFormatter.java:163)
	at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.format(DefaultCodeFormatter.java:146)
	at org.eclipse.jdt.internal.corext.util.CodeFormatterUtil.reformat(CodeFormatterUtil.java:288)
	at org.eclipse.jdt.internal.ui.text.java.JavaFormattingStrategy.format(JavaFormattingStrategy.java:65)
	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.jface.text.source.SourceViewer.doOperation(SourceViewer.java:960)
	at org.eclipse.jface.text.source.projection.ProjectionViewer.doOperation(ProjectionViewer.java:1534)
	at org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer.doOperation(JavaSourceViewer.java:186)
	at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewer.doOperation(CompilationUnitEditor.java:199)
	at org.eclipse.ui.texteditor.TextOperationAction$1.run(TextOperationAction.java:131)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.ui.texteditor.TextOperationAction.run(TextOperationAction.java:129)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
	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:476)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
	at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:468)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:786)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:885)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:567)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:508)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:123)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1247)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1049)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1074)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1059)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1100)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1096)
	at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1505)
	at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:4069)
	at org.eclipse.swt.widgets.Canvas.WM_CHAR(Canvas.java:345)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:3961)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:341)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4766)
	at org.eclipse.swt.internal.win32.OS.$$YJP$$CallWindowProcW(Native Method)
	at org.eclipse.swt.internal.win32.OS.CallWindowProcW(OS.java)
	at org.eclipse.swt.internal.win32.OS.CallWindowProc(OS.java:2353)
	at org.eclipse.swt.internal.BidiUtil.windowProc(BidiUtil.java:639)
	at org.eclipse.swt.internal.win32.OS.$$YJP$$DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(OS.java)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2450)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3603)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2408)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2372)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:501)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:494)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:195)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	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.equinox.launcher.Main.invokeFramework(Main.java:611)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:566)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1363)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1339)
Comment 1 Markus Keller CLA 2010-03-03 10:58:14 EST
Similar problem when only enabling_tag is set.
Comment 2 Frederic Fusier CLA 2010-03-03 11:30:48 EST
Created attachment 160798 [details]
Proposed patch

The scanner sorts the array of task tags, hence no slot should be null in this array...
Comment 3 Frederic Fusier CLA 2010-03-03 11:32:43 EST
(In reply to comment #2)
> Created an attachment (id=160798) [details]
> Proposed patch
> 
Released for 3.6M6 in HEAD stream.
Comment 4 Olivier Thomann CLA 2010-03-09 16:19:49 EST
Verified for 3.6M6 using I20100309-0809