Project: JDT
Bug 40452 refactor rename throws StringIndexOutOfBounds exception
Reported: 2003-07-18 05:28:19 | Status: resolved fixed

------------------A.java--------------------- package a; public class A { public static void method2() //<--- refactor rename this method { } } ---------------------------------------------- -----------------------B.java----------------- package b; import a.A; public class B { I i = new I() { public void method() { A.method2(); } }; } interface I { void method(); } -------------------------------------------------- If you have the above two files and refactor rename "method2" to something you get the following: java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.runInCurrentThread(Unknown Source) at org.eclipse.jface.operation.ModalContext.run(Unknown Source) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.run(Unknown Source) at org.eclipse.jdt.internal.ui.refactoring.PerformRefactoringUtil.performRefactorin g(Unknown Source) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.performFinish (Unknown Source) at org.eclipse.jdt.internal.ui.refactoring.UserInputWizardPage.performFinish (Unknown Source) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.performFinish (Unknown Source) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.okPressed (Unknown Source) at org.eclipse.jface.dialogs.Dialog.buttonPressed(Unknown Source) at org.eclipse.jface.dialogs.Dialog$1.widgetSelected(Unknown Source) 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:848) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2188) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1878) at org.eclipse.jface.window.Window.runEventLoop(Unknown Source) at org.eclipse.jface.window.Window.open(Unknown Source) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (Unknown Source) at org.eclipse.jdt.internal.ui.refactoring.reorg.RenameRefactoringAction.run (Unknown Source) at org.eclipse.jdt.ui.refactoring.RenameSupport.openDialog(Unknown Source) at org.eclipse.jdt.internal.ui.refactoring.actions.RenameJavaElementAction.run (Unknown Source) at org.eclipse.jdt.internal.ui.refactoring.actions.RenameJavaElementAction.run (Unknown Source) at org.eclipse.jdt.ui.actions.RenameAction.run(Unknown Source) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(Unknown Source) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(Unknown Source) at org.eclipse.jface.action.Action.runWithEvent(Unknown Source) at org.eclipse.ui.internal.commands.old.ActionHandler.execute(Unknown Source) at org.eclipse.ui.internal.commands.old.ContextAndHandlerManager.pressed (Unknown Source) at org.eclipse.ui.internal.commands.old.ContextAndHandlerManager.access$1 (Unknown Source) at org.eclipse.ui.internal.commands.old.ContextAndHandlerManager$7.widgetSelected (Unknown Source) at org.eclipse.ui.internal.AcceleratorMenu$2.handleEvent(Unknown Source) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:848) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2188) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1878) at org.eclipse.ui.internal.Workbench.runEventLoop(Unknown Source) at org.eclipse.ui.internal.Workbench.run(Unknown Source) at org.eclipse.core.internal.boot.InternalBootLoader.run(Unknown Source) at org.eclipse.core.boot.BootLoader.run(Unknown Source) 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(Unknown Source) at org.eclipse.core.launcher.Main.run(Unknown Source) at org.eclipse.core.launcher.Main.main(Unknown Source) Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -7 at java.lang.String.substring(String.java:1444) at java.lang.String.substring(String.java:1411) at org.eclipse.jdt.internal.corext.refactoring.rename.UpdateMethodReferenceEdit.con nect(Unknown Source) at org.eclipse.jdt.internal.corext.textmanipulation.TextEdit.executeConnect (Unknown Source) at org.eclipse.jdt.internal.corext.textmanipulation.AutoOrganizingTextEdit.executeC onnect(Unknown Source) at org.eclipse.jdt.internal.corext.textmanipulation.TextBufferEditor.add (Unknown Source) at org.eclipse.jdt.internal.corext.refactoring.changes.TextChange.addTextEdits (Unknown Source) at org.eclipse.jdt.internal.corext.refactoring.changes.TextChange.getPreviewTextBuf fer(Unknown Source) at org.eclipse.jdt.internal.corext.refactoring.rename.RenameAnalyzeUtil.getNewWorki ngCopies(Unknown Source) at org.eclipse.jdt.internal.corext.refactoring.rename.RenameMethodProcessor.getNewO ccurrences(Unknown Source) at org.eclipse.jdt.internal.corext.refactoring.rename.RenameMethodProcessor.analyze RenameChanges(Unknown Source) at org.eclipse.jdt.internal.corext.refactoring.rename.RenameMethodProcessor.checkIn put(Unknown Source) at org.eclipse.jdt.internal.corext.refactoring.rename.RenameNonVirtualMethodProcess or.checkInput(Unknown Source) at org.eclipse.jdt.internal.corext.refactoring.rename.RenameRefactoring.checkInput (Unknown Source) at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run(Unknown Source) at org.eclipse.jdt.internal.ui.refactoring.CreateChangeOperation.run(Unknown Source) at org.eclipse.jdt.internal.ui.refactoring.PerformChangeOperation.run(Unknown Source) ... 46 more

Files changed in fix:
org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameStaticMethodTests.java