Community
Participate
Working Groups
I20030107 Had this code in editor: for (int i= 0; i < versions.length; i++) { String version= versions[i]; if (findVMInstall(version) == null) { String path= "/System/Library/Frameworks/JavaVM.framework/Versions/"+version+"/Home"; File home = new File(path); if (home.exists()) { createVMInstall(version); if (javaHome != null && javaHome.equals(path)) { if (JavaRuntime.getDefaultVMInstall() == null) { IVMInstall vm= findVMInstall(version); if (vm != null) { JavaRuntime.setDefaultVMInstall(vm, null); } } } } } }
[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.