Project: JDT
Bug 15747 StringIndexOutOfBoundsException from extract method
Reported: 2002-05-10 11:14:12 | Status: resolved fixed

!STACK java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.substring(String.java(Compiled Code)) at org.eclipse.jdt.internal.corext.codemanipulation.MethodBlock.fill (MethodBlock.java:52) at org.eclipse.jdt.internal.corext.codemanipulation.CodeBlockEdit.createText (CodeBlockEdit.java:123) at org.eclipse.jdt.internal.corext.codemanipulation.CodeBlockEdit.perform (CodeBlockEdit.java:94) at org.eclipse.jdt.internal.corext.textmanipulation.TextEditNode.performDo (TextEditNode.java:444) at org.eclipse.jdt.internal.corext.textmanipulation.TextEditNode.performDo (TextEditNode.java:438) at org.eclipse.jdt.internal.corext.textmanipulation.TextEditNode$RootNode.performDo (TextEditNode.java:49) at org.eclipse.jdt.internal.corext.textmanipulation.TextBufferEditor.performEdits (TextBufferEditor.java:173) at org.eclipse.jdt.internal.corext.refactoring.changes.TextChange.getPreviewTextBuf fer(TextChange.java:188) at org.eclipse.jdt.internal.corext.refactoring.changes.TextChange.getPreviewContent (TextChange.java:178) at org.eclipse.jdt.internal.ui.refactoring.PreviewWizardPage.getCompareInput (PreviewWizardPage.java:236) at org.eclipse.jdt.internal.ui.refactoring.PreviewWizardPage.getPreviewer (PreviewWizardPage.java:298) at org.eclipse.jdt.internal.ui.refactoring.PreviewWizardPage.showPreview (PreviewWizardPage.java:429) at org.eclipse.jdt.internal.ui.refactoring.PreviewWizardPage.access$2 (PreviewWizardPage.java:427) at org.eclipse.jdt.internal.ui.refactoring.PreviewWizardPage$2.selectionChanged (PreviewWizardPage.java:418) at org.eclipse.jface.viewers.Viewer.fireSelectionChanged(Viewer.java (Compiled Code)) at org.eclipse.jface.viewers.StructuredViewer.updateSelection (StructuredViewer.java:1064) at org.eclipse.jface.viewers.StructuredViewer.setSelection (StructuredViewer.java:813) at org.eclipse.jface.viewers.Viewer.setSelection(Viewer.java:342) at org.eclipse.jdt.internal.ui.refactoring.PreviewWizardPage.setVisible (PreviewWizardPage.java:383) at org.eclipse.jface.wizard.WizardDialog.showPage(WizardDialog.java:888) at org.eclipse.jface.wizard.WizardDialog.nextPressed (WizardDialog.java:653) at org.eclipse.jface.wizard.WizardDialog.buttonPressed (WizardDialog.java:308) at org.eclipse.jface.dialogs.Dialog$1.widgetSelected(Dialog.java:398) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java (Compiled Code)) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java (Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.jface.window.Window.runEventLoop(Window.java(Compiled Code)) at org.eclipse.jface.window.Window.open(Window.java:535) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:79) at org.eclipse.jdt.ui.actions.ExtractMethodAction.run (ExtractMethodAction.java:45) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:135) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:95) at org.eclipse.jface.action.Action.runWithEvent(Action.java:590) at org.eclipse.ui.actions.RetargetAction.runWithEvent (RetargetAction.java:155) at org.eclipse.ui.internal.WWinPluginAction.runWithEvent (WWinPluginAction.java:170) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java(Compiled Code)) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java (Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled Code)) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java (Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java (Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1045) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:739) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:450) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:174) at org.eclipse.core.launcher.Main.run(Main.java:605) at org.eclipse.core.launcher.Main.main(Main.java:449)

Files changed in fix:
org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/codemanipulation/MethodBlock.java org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/codemanipulation/TryCatchBlock.java