Project: JDT
Bug 127922 NPE when invoking quick fix
Reported: 2006-02-14 17:09:59 | Status: resolved fixed

I was trying out the quick fix feature from the problems view and found the NPE below. I think it happens because the Quick Fix is enabled but no resolutions are actually present. To re-create, put a space in the middle of one of your imported class names and save. In the Problems view, select the problem that says "<className> cannot be resolved" and select QuickFix. The quick fix dialog comes up but the list of resolutions is empty and the NPE is written to the log java.lang.NullPointerException at org.eclipse.jdt.internal.corext.dom.ScopeAnalyzer.isVisible(ScopeAnalyzer.java:528) at org.eclipse.jdt.internal.corext.dom.ScopeAnalyzer$DefaultBindingRequestor.acceptBinding(ScopeAnalyzer.java:106) at org.eclipse.jdt.internal.corext.dom.ScopeAnalyzer$ScopeAnalyzerVisitor.visit(ScopeAnalyzer.java:658) at org.eclipse.jdt.internal.corext.dom.HierarchicalASTVisitor.visit(HierarchicalASTVisitor.java:743) at org.eclipse.jdt.core.dom.VariableDeclarationFragment.accept0(VariableDeclarationFragment.java(Compiled Code)) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java(Compiled Code)) at org.eclipse.jdt.internal.corext.dom.ScopeAnalyzer$ScopeAnalyzerVisitor.visitBackwards(ScopeAnalyzer.java:708) at org.eclipse.jdt.internal.corext.dom.ScopeAnalyzer$ScopeAnalyzerVisitor.visit(ScopeAnalyzer.java:664) at org.eclipse.jdt.core.dom.VariableDeclarationStatement.accept0(VariableDeclarationStatement.java:265) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java(Compiled Code)) at org.eclipse.jdt.internal.corext.dom.ScopeAnalyzer$ScopeAnalyzerVisitor.visitBackwards(ScopeAnalyzer.java:708) at org.eclipse.jdt.internal.corext.dom.ScopeAnalyzer$ScopeAnalyzerVisitor.visit(ScopeAnalyzer.java:651) at org.eclipse.jdt.core.dom.Block.accept0(Block.java:133) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java(Compiled Code)) at org.eclipse.jdt.internal.corext.dom.ScopeAnalyzer$ScopeAnalyzerVisitor.visit(ScopeAnalyzer.java:596) at org.eclipse.jdt.core.dom.MethodDeclaration.accept0(MethodDeclaration.java:486) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java(Compiled Code)) at org.eclipse.jdt.internal.corext.dom.ScopeAnalyzer.addLocalDeclarations(ScopeAnalyzer.java:764) at org.eclipse.jdt.internal.corext.dom.ScopeAnalyzer.addLocalDeclarations(ScopeAnalyzer.java:755) at org.eclipse.jdt.internal.corext.dom.ScopeAnalyzer.getDeclarationsInScope(ScopeAnalyzer.java:341) at org.eclipse.jdt.internal.ui.text.correction.UnresolvedElementsSubProcessor.addSimilarVariableProposals(UnresolvedElementsSubProcessor.java:348) at org.eclipse.jdt.internal.ui.text.correction.UnresolvedElementsSubProcessor.getVariableProposals(UnresolvedElementsSubProcessor.java:230) at org.eclipse.jdt.internal.ui.text.correction.QuickFixProcessor.process(QuickFixProcessor.java:262) at org.eclipse.jdt.internal.ui.text.correction.QuickFixProcessor.getCorrections(QuickFixProcessor.java:218) at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor$SafeCorrectionCollector.safeRun(JavaCorrectionProcessor.java:343) at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor$SafeCorrectionProcessorAccess.run(JavaCorrectionProcessor.java:305) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java(Compiled Code)) at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor$SafeCorrectionProcessorAccess.process(JavaCorrectionProcessor.java:301) at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor.collectCorrections(JavaCorrectionProcessor.java:430) at org.eclipse.jdt.internal.ui.text.correction.CorrectionMarkerResolutionGenerator.internalGetResolutions(CorrectionMarkerResolutionGenerator.java:401) at org.eclipse.jdt.internal.ui.text.correction.CorrectionMarkerResolutionGenerator.getResolutions(CorrectionMarkerResolutionGenerator.java:374) at org.eclipse.ui.internal.ide.registry.MarkerHelpRegistry.getResolutions(MarkerHelpRegistry.java:200) at org.eclipse.ui.views.markers.internal.ActionResolveMarker$1.run(ActionResolveMarker.java:70) at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:360) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:305) at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:453) at org.eclipse.ui.internal.progress.ProgressManager$5.run(ProgressManager.java:1094) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java(Compiled Code)) at org.eclipse.ui.internal.progress.ProgressManager.runInUI(ProgressManager.java:1090) at org.eclipse.ui.internal.progress.WorkbenchSiteProgressService.runInUI(WorkbenchSiteProgressService.java:330) at org.eclipse.ui.views.markers.internal.ActionResolveMarker.run(ActionResolveMarker.java:83) at org.eclipse.jface.action.Action.runWithEvent(Action.java:492) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:530) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:480) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:392) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java(Inlined Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java(Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java(Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java(Compiled Code)) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1863) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:417) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:106) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:99) 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:374) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:169) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60) at java.lang.reflect.Method.invoke(Method.java:391) at org.eclipse.core.launcher.Main.invokeFramework(Main.java:338) at org.eclipse.core.launcher.Main.basicRun(Main.java:282) at org.eclipse.core.launcher.Main.run(Main.java:977) at org.eclipse.core.launcher.Main.main(Main.java:952)

Files changed in fix:
org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/dom/ScopeAnalyzer.java