Project: JDT
Bug 7229 surround try/catch block throws NPE
Reported: 2002-01-03 06:54:18 | Status: resolved fixed

Workspace version on Linux and Windows: If the compilation unit has errors, it throws an NPE. -- public class Foo { public static void main(String[] args) { System.out.println(""); // select this line and call surround try/catch a // syntax error } } -- 4 org.eclipse.ui 0 java.lang.NullPointerException java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.util.AST.accept(AST.java:70) at org.eclipse.jdt.internal.corext.refactoring.surround.SurroundWithTryCatchRefactoring.checkActivation(SurroundWithTryCatchRefactoring.java:102) at org.eclipse.jdt.internal.ui.refactoring.actions.SurroundWithTryCatchAction.run(SurroundWithTryCatchAction.java:42) at org.eclipse.jface.action.Action.runWithEvent(Action.java:452) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent(ActionContributionItem.java:361) at org.eclipse.jface.action.ActionContributionItem.access$0(ActionContributionItem.java:352) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent(ActionContributionItem.java:47) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:54) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:489) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1569) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1423) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:815) at org.eclipse.ui.internal.Workbench.run(Workbench.java:798) at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:820) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285) at SlimLauncher.main(SlimLauncher.java:14)

Files changed in fix:
org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/Strings.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/base/RefactoringStatus.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractMethodAnalyzer.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractMethodRefactoring.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/surround/SurroundWithTryCatchRefactoring.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/util/AST.java org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/RefactoringStatusEntryLabelProvider.java org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/actions/ListDialog.java org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/actions/RefactoringAction.java org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/actions/SurroundWithTryCatchAction.java org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/actions/TextSelectionAction.java org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/actions/TextSelectionBasedRefactoringAction.java