Summary: | NPE in Surround with try/catch block [refactoring] | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Andre Weinand <andre_weinand> |
Component: | Core | Assignee: | Olivier Thomann <Olivier_Thomann> |
Status: | VERIFIED FIXED | QA Contact: | |
Severity: | major | ||
Priority: | P2 | CC: | Darin_Swanson, dirk_baeumer, martinae, Michael.Valenta |
Version: | 2.1 | ||
Target Milestone: | 2.1 M5 | ||
Hardware: | Macintosh | ||
OS: | Mac OS X - Carbon (unsup.) | ||
Whiteboard: |
Description
Andre Weinand
2003-01-08 11:50:31 EST
[Oops, Safari seems to have problems with text pasted into this field...] - selected line containing "JavaRuntime..." - selected "surround with try/catch block" from context menu - got this NPE: !ENTRY org.eclipse.ui 4 0 Jan 08, 2003 17:57:22.179 !MESSAGE java.lang.NullPointerException !STACK 0 java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.changes.TextFileChange.perform(TextFileChange.java:203) at org.eclipse.jdt.internal.ui.refactoring.PerformChangeOperation$1.run(PerformChangeOperation.java:173) at org.eclipse.jdt.internal.core.BatchOperation.executeOperation(BatchOperation.java:34) at org.eclipse.jdt.internal.core.JavaModelOperation.execute(JavaModelOperation.java:326) at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:626) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1564) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:2571) at org.eclipse.jdt.internal.ui.refactoring.PerformChangeOperation.executeChange(PerformChangeOperation.java:183) at org.eclipse.jdt.internal.ui.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:151) at org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext$BusyRunnable.internalRun(BusyIndicatorRunnableContext.java:107) at org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext$BusyRunnable.run(BusyIndicatorRunnableContext.java:74) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:65) at org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext.run(BusyIndicatorRunnableContext.java:120) at org.eclipse.jdt.ui.actions.SurroundWithTryCatchAction.run(SurroundWithTryCatchAction.java:110) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:193) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:169) at org.eclipse.jface.action.Action.runWithEvent(Action.java:769) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:411) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent(ActionContributionItem.java:365) at org.eclipse.jface.action.ActionContributionItem.access$0(ActionContributionItem.java:356) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent(ActionContributionItem.java:48) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:77) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:623) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1252) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1009) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1467) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1450) at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:845) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:462) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:247) at org.eclipse.core.launcher.Main.run(Main.java:703) at org.eclipse.core.launcher.Main.main(Main.java:539) at java.lang.reflect.Method.invoke(Native Method) at apple.launcher.LaunchRunner.run(LaunchRunner.java:88) at apple.launcher.LaunchRunner.callMain(LaunchRunner.java:50) at apple.launcher.JavaApplicationLauncher.launch(JavaApplicationLauncher.java:52) java.lang.NullPointerException *** Bug 29547 has been marked as a duplicate of this bug. *** *** Bug 29549 has been marked as a duplicate of this bug. *** This is caused by code in the Java Core which magically converts an instance of a NullProgressMonitor into null. Your refactoring code doesn't assume at every place that the progress monitor can be null, since we make sure at the beginning of an operation that the progress monitor != null. The problematic code is JavaModelOperation.run(...) { fMonitor = monitor instanceof NullProgressMonitor ? null/*workaround for http://bugs.eclipse.org/bugs/show_bug.cgi?id=25529*/ : monitor; } IMO core can't replace a valid progress monitor through null even if it is an instance of NullProgressMonitor since this can cause NPE. Moving to JDT Core. I removed this check that replace NullProgressMonitor with null. All JDT/Core tests passed. Fixed and released in 2.1 stream. *** Bug 30023 has been marked as a duplicate of this bug. *** Verified. |