Project: JDT
Bug 47785 Exception in Extract Interface refactoring [refactoring]
Reported: 2003-12-01 05:43:11 | Status: verified fixed

Eclipse M5 1) Import JUnit 3.8.1 (as per Smoke test) 2) In the package explorer, select junit.runner.BaseTestRunner 3) From the context menu, select Refactor->Extract Interface 4) Input a name for the interface, select all methods 5) press the preview button 6) observe: you get an exception: java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:283) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.run(RefactoringWizardDialog2.java:271) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.createChange(RefactoringWizard.java:377) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.computeUserInputSuccessorPage(RefactoringWizard.java:297) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.computeUserInputSuccessorPage(RefactoringWizard.java:293) at org.eclipse.jdt.internal.ui.refactoring.UserInputWizardPage.getNextPage(UserInputWizardPage.java:79) at org.eclipse.jdt.internal.ui.refactoring.ExtractInterfaceWizard$ExtractInterfaceInputPage.getNextPage(ExtractInterfaceWizard.java:278) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.previewPressed(RefactoringWizardDialog2.java:418) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.access$3(RefactoringWizardDialog2.java:416) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2$1.widgetSelected(RefactoringWizardDialog2.java:547) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:89) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:847) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2187) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1877) at org.eclipse.jface.window.Window.runEventLoop(Window.java:586) at org.eclipse.jface.window.Window.open(Window.java:566) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:56) at org.eclipse.jdt.ui.actions.ExtractInterfaceAction.startRefactoring(ExtractInterfaceAction.java:173) at org.eclipse.jdt.ui.actions.ExtractInterfaceAction.run(ExtractInterfaceAction.java:105) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:194) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:172) at org.eclipse.jface.action.Action.runWithEvent(Action.java:842) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:542) at org.eclipse.jface.action.ActionContributionItem.access$4(ActionContributionItem.java:494) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:466) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:847) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2187) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1877) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1405) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1381) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:237) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:47) at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:858) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461) 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:299) at org.eclipse.core.launcher.Main.run(Main.java:767) at org.eclipse.core.launcher.Main.main(Main.java:601) Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -4 at java.lang.String.<init>(String.java:192) at org.eclipse.jdt.internal.core.Buffer.getText(Buffer.java:168) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createInterfaceMethodDeclarationsSource(ExtractInterfaceRefactoring.java:568) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createInterfaceMemberDeclarationsSource(ExtractInterfaceRefactoring.java:545) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createInterfaceMemberDeclarationsSource(ExtractInterfaceRefactoring.java:519) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createInterfaceSource(ExtractInterfaceRefactoring.java:501) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createExtractedInterfaceCUSource(ExtractInterfaceRefactoring.java:477) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createChangeManager(ExtractInterfaceRefactoring.java:309) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.checkInput(ExtractInterfaceRefactoring.java:215) at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:65) at org.eclipse.jdt.internal.ui.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:100) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:101)

Files changed in fix:
org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test100/in/A.java org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test100/out/A.java org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test100/out/I.java org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractInterfaceTests.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ExtractInterfaceRefactoring.java