Bug 311864 - [formatter] NPE with empty {@code }
Summary: [formatter] NPE with empty {@code }
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.6   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.6 RC1   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-06 08:32 EDT by Stefan Liebig CLA
Modified: 2010-05-17 01:20 EDT (History)
2 users (show)

See Also:
Olivier_Thomann: review+


Attachments
Proposed patch (3.43 KB, patch)
2010-05-06 10:24 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 Stefan Liebig CLA 2010-05-06 08:32:22 EDT
I am using 3.6M7. Formatting Java code results in a NPE:

java.lang.NullPointerException
at org.eclipse.jdt.internal.formatter.Scribe.printJavadocBlockN odesNewLines(Scribe.java:3123)
at org.eclipse.jdt.internal.formatter.Scribe.printJavadocBlock( Scribe.java:3057)
at org.eclipse.jdt.internal.formatter.Scribe.printJavadocCommen t(Scribe.java:3442)
at org.eclipse.jdt.internal.formatter.Scribe.printComment(Scrib e.java:2490)
at org.eclipse.jdt.internal.formatter.Scribe.printComment(Scrib e.java:2253)
at org.eclipse.jdt.internal.formatter.CodeFormatterVisitor.visi t(CodeFormatterVisitor.java:4201)
at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.trav erse(MethodDeclaration.java:230)
at org.eclipse.jdt.internal.formatter.CodeFormatterVisitor.form at(CodeFormatterVisitor.java:540)
at org.eclipse.jdt.internal.formatter.CodeFormatterVisitor.form atTypeMembers(CodeFormatterVisitor.java:2078)
at org.eclipse.jdt.internal.formatter.CodeFormatterVisitor.form at(CodeFormatterVisitor.java:1163)
at org.eclipse.jdt.internal.formatter.CodeFormatterVisitor.visi t(CodeFormatterVisitor.java:5322)
at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traver se(TypeDeclaration.java:1249)
at org.eclipse.jdt.internal.formatter.CodeFormatterVisitor.visi t(CodeFormatterVisitor.java:3133)
at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclara tion.traverse(CompilationUnitDeclaration.java:649)
at org.eclipse.jdt.internal.formatter.CodeFormatterVisitor.form at(CodeFormatterVisitor.java:810)
at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.form atCompilationUnit(DefaultCodeFormatter.java:241)
at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.form at(DefaultCodeFormatter.java:163)
at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.form at(DefaultCodeFormatter.java:146)
at org.eclipse.jdt.internal.corext.util.CodeFormatterUtil.refor mat(CodeFormatterUtil.java:288)
at org.eclipse.jdt.internal.ui.text.java.JavaFormattingStrategy .format(JavaFormattingStrategy.java:65)
at org.eclipse.jface.text.formatter.MultiPassContentFormatter.f ormatMaster(MultiPassContentFormatter.java:193)
at org.eclipse.jface.text.formatter.MultiPassContentFormatter.f ormat(MultiPassContentFormatter.java:142)
at org.eclipse.jface.text.source.SourceViewer.doOperation(Sourc eViewer.java:960)
at org.eclipse.jface.text.source.projection.ProjectionViewer.do Operation(ProjectionViewer.java:1534)
at org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer.doOp eration(JavaSourceViewer.java:186)
at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor $AdaptedSourceViewer.doOperation(CompilationUnitEditor.java: 199)
at org.eclipse.ui.texteditor.TextOperationAction$1.run(TextOper ationAction.java:131)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:70)
at org.eclipse.ui.texteditor.TextOperationAction.run(TextOperat ionAction.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.execut e(LegacyHandlerWrapper.java:109)
at org.eclipse.core.commands.Command.executeWithChecks(Command. java:476)
at org.eclipse.core.commands.ParameterizedCommand.executeWithCh ecks(ParameterizedCommand.java:508)
at org.eclipse.ui.internal.handlers.HandlerService.executeComma nd(HandlerService.java:169)
at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeComman d(WorkbenchKeyboard.java:468)
at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(Workben chKeyboard.java:786)
at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEve nt(WorkbenchKeyboard.java:885)
at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequ enceBindings(WorkbenchKeyboard.java:567)
at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(Work benchKeyboard.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:125 3)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1051)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1076)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1102 )
at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1098 )
at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1507)
at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:4267)
at org.eclipse.swt.widgets.Canvas.WM_CHAR(Canvas.java:345)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4159 )
at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:341)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4873 )
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:24 59)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3655)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2601)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2565)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:23 99)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:669)
at org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:662)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:115)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:196)
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(EclipseS tarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 619)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
at org.eclipse.equinox.launcher.Main.main(Main.java:1383)

I debugged a little bit and I found that this JavaDoc comment was the cause:

/**
* Compares two property values. For font or color the <i>description</i> of
* the resource, {@link FontData} or {@link RGB}, is used for comparison.
*
* @param value1
* first property value
* @param value2
* second property value
* @return {@code true} if the values are equals; otherwise {@code}
*/

The problem is the empty {@code} block in the @return.

Tschüß,
Stefan
Comment 1 Frederic Fusier CLA 2010-05-06 10:24:59 EDT
Created attachment 167311 [details]
Proposed patch

Yes, a null check was missing there :-(
Comment 2 Frederic Fusier CLA 2010-05-06 10:25:27 EDT
Olivier, please review, thanks
Comment 3 Olivier Thomann CLA 2010-05-06 10:30:28 EDT
+1 for RC1.
Comment 4 Frederic Fusier CLA 2010-05-06 11:23:58 EDT
(In reply to comment #1)
> Created an attachment (id=167311) [details]
> Proposed patch
> 
Released for 3.6RC1 in HEAD stream.
Comment 5 Srikanth Sankaran CLA 2010-05-17 01:20:30 EDT
Verified for 3.6RC1 using Build id: I20100513-1500