Bug 16132 - Error on Extract Method Refactoring
Summary: Error on Extract Method Refactoring
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows NT
: P2 critical (vote)
Target Milestone: 2.0 M6   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-05-16 08:09 EDT by Rainer Schmitz CLA
Modified: 2002-05-16 11:09 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rainer Schmitz CLA 2002-05-16 08:09:38 EDT
Selecting some code within a method body and choosing "extract method" produces
the following error:


java.lang.NullPointerException
	at org.eclipse.jdt.core.dom.ASTConverter.checkForParenthesis(ASTConverter.java:2607)
	at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:674)
	at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1657)
	at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1572)
	at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:646)
	at org.eclipse.jdt.core.dom.ASTConverter.buildBodyDeclarations(ASTConverter.java:228)
	at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:168)
	at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:73)
	at org.eclipse.jdt.core.dom.AST.parseCompilationUnit(AST.java:234)
	at
org.eclipse.jdt.internal.corext.refactoring.code.ExtractMethodRefactoring.checkActivation(ExtractMethodRefactoring.java:165)
	at
org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:74)
	at
org.eclipse.jdt.internal.ui.refactoring.actions.TextSelectionBasedRefactoringAction.run(TextSelectionBasedRefactoringAction.java:29)
	at
org.eclipse.jdt.internal.ui.refactoring.actions.TextSelectionAction.run(TextSelectionAction.java:80)
	at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:202)
	at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:162)
	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:75)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:637)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1412)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1208)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:836)
	at org.eclipse.ui.internal.Workbench.run(Workbench.java:819)
	at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:777)
	at org.eclipse.core.boot.BootLoader.run(BootLoader.java:319)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:324)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:190)
	at org.eclipse.core.launcher.Main.run(Main.java:549)
	at org.eclipse.core.launcher.Main.main(Main.java:390)
Comment 1 Olivier Thomann CLA 2002-05-16 09:48:27 EDT
It would be nice to know which build you are using and the piece of code you selected.
Comment 2 Rainer Schmitz CLA 2002-05-16 10:09:51 EDT
Build 20020416, JDK 1.4

While providing a test case i figured the bug only occurs if in the class
contains an assert statement (JDK 1.4). This can be anywhere, not nesseccarily
in the method to refactor.

Testcase:
Try extract method on a line of method bugTest() (will not work), then comment
out the assert statement in containsAssert() and try again (will work):

public class BugTest {

    public void bugTest() {
        System.out.println("bla");
        System.out.println("blubb");
    }

    private void containsAssert() {
        assert true;
    }

}
Comment 3 Olivier Thomann CLA 2002-05-16 10:13:24 EDT
Ok, thanks for the test case. I am working on it.
Comment 4 Olivier Thomann CLA 2002-05-16 10:23:27 EDT
A quick question to be sure. Is your compiler set to accept assert statements?
Comment 5 Rainer Schmitz CLA 2002-05-16 10:28:13 EDT
Yes.
Settings:
Preferences -> Java -> Compiler -> Compiler compliance level: 1.4
Use default compliance settings.

Everything compiles and works as expected (even "Organize Imports" which used to
hickup on assert some builds ago)
Comment 6 Olivier Thomann CLA 2002-05-16 10:38:44 EDT
I successfully reproduced the problem. It should be fixed today.
Comment 7 Olivier Thomann CLA 2002-05-16 10:58:26 EDT
Fixed and released in HEAD.
Comment 8 Olivier Thomann CLA 2002-05-16 11:09:02 EDT
Fixed.