Bug 7229

Summary: surround try/catch block throws NPE
Product: [Eclipse Project] JDT Reporter: Claude Knaus <Claude_Knaus>
Component: UIAssignee: Dirk Baeumer <dirk_baeumer>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P2    
Version: 2.0   
Target Milestone: 2.0 M3   
Hardware: PC   
OS: All   
Whiteboard:

Description Claude Knaus CLA 2002-01-03 06:54:18 EST
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)
Comment 1 Dirk Baeumer CLA 2002-01-15 13:30:59 EST
Fixed in build > xI-20020115