Project: JDT
Bug 159100 Add Import gives ArrayIndexOutOfBoundsException
Reported: 2006-09-28 06:58:44 | Status: resolved fixed

HEAD 1. have JUnit in workspace 2. open TestCase 3. go to run(TestResult result) methid 4. in the body insert "Text f;" above "result.run(this);" 5. place the caret after "Text f;" 6. Ctrl+Shift+M ==> !ENTRY org.eclipse.jdt.ui 4 10001 2006-09-28 12:59:28.130 !MESSAGE Internal Error !STACK 0 java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:381) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:313) at org.eclipse.jface.window.ApplicationWindow$1.run(ApplicationWindow.java:767) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67) at org.eclipse.jface.window.ApplicationWindow.run(ApplicationWindow.java:764) at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:2280) at org.eclipse.ui.internal.progress.ProgressManager$5.run(ProgressManager.java:1130) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67) at org.eclipse.ui.internal.progress.ProgressManager.runInUI(ProgressManager.java:1123) at org.eclipse.jdt.internal.ui.javaeditor.AddImportOnSelectionAction.run(AddImportOnSelectionAction.java:136) at org.eclipse.jface.action.Action.runWithEvent(Action.java:499) at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:185) at org.eclipse.ui.internal.handlers.LegacyHandlerWrapper.execute(LegacyHandlerWrapper.java:109) at org.eclipse.core.commands.Command.executeWithChecks(Command.java:461) at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:424) at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:160) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:465) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:793) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:840) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:563) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:505) at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:122) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Display.filterEvent(Display.java:996) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:927) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:952) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:937) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:965) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:961) at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1275) at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3352) at org.eclipse.swt.widgets.Control.windowProc(Control.java:3252) at org.eclipse.swt.widgets.Display.windowProc(Display.java:4070) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1977) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3018) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1914) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1878) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:419) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:95) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:104) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:74) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:348) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:165) 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.invokeFramework(Main.java:341) at org.eclipse.core.launcher.Main.basicRun(Main.java:285) at org.eclipse.core.launcher.Main.run(Main.java:987) at org.eclipse.core.launcher.Main.main(Main.java:962) Caused by: java.lang.ArrayIndexOutOfBoundsException: 0 at org.eclipse.jdt.internal.core.search.BasicSearchEngine.match(BasicSearchEngine.java:462) at org.eclipse.jdt.internal.core.search.BasicSearchEngine.searchAllTypeNames(BasicSearchEngine.java:810) at org.eclipse.jdt.core.search.SearchEngine.searchAllTypeNames(SearchEngine.java:603) at org.eclipse.jdt.internal.corext.codemanipulation.AddImportsOperation.findAllTypes(AddImportsOperation.java:377) at org.eclipse.jdt.internal.corext.codemanipulation.AddImportsOperation.evaluateEdits(AddImportsOperation.java:279) at org.eclipse.jdt.internal.corext.codemanipulation.AddImportsOperation.run(AddImportsOperation.java:150) at org.eclipse.jdt.internal.core.BatchOperation.executeOperation(BatchOperation.java:39) at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:720) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1737) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:4022) at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:87) at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:369) ... 53 more Root exception: java.lang.ArrayIndexOutOfBoundsException: 0 at org.eclipse.jdt.internal.core.search.BasicSearchEngine.match(BasicSearchEngine.java:462) at org.eclipse.jdt.internal.core.search.BasicSearchEngine.searchAllTypeNames(BasicSearchEngine.java:810) at org.eclipse.jdt.core.search.SearchEngine.searchAllTypeNames(SearchEngine.java:603) at org.eclipse.jdt.internal.corext.codemanipulation.AddImportsOperation.findAllTypes(AddImportsOperation.java:377) at org.eclipse.jdt.internal.corext.codemanipulation.AddImportsOperation.evaluateEdits(AddImportsOperation.java:279) at org.eclipse.jdt.internal.corext.codemanipulation.AddImportsOperation.run(AddImportsOperation.java:150) at org.eclipse.jdt.internal.core.BatchOperation.executeOperation(BatchOperation.java:39) at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:720) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1737) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:4022) at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:87) at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:369) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:313) at org.eclipse.jface.window.ApplicationWindow$1.run(ApplicationWindow.java:767) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67) at org.eclipse.jface.window.ApplicationWindow.run(ApplicationWindow.java:764) at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:2280) at org.eclipse.ui.internal.progress.ProgressManager$5.run(ProgressManager.java:1130) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67) at org.eclipse.ui.internal.progress.ProgressManager.runInUI(ProgressManager.java:1123) at org.eclipse.jdt.internal.ui.javaeditor.AddImportOnSelectionAction.run(AddImportOnSelectionAction.java:136) at org.eclipse.jface.action.Action.runWithEvent(Action.java:499) at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:185) at org.eclipse.ui.internal.handlers.LegacyHandlerWrapper.execute(LegacyHandlerWrapper.java:109) at org.eclipse.core.commands.Command.executeWithChecks(Command.java:461) at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:424) at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:160) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:465) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:793) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:840) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:563) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:505) at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:122) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Display.filterEvent(Display.java:996) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:927) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:952) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:937) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:965) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:961) at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1275) at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3352) at org.eclipse.swt.widgets.Control.windowProc(Control.java:3252) at org.eclipse.swt.widgets.Display.windowProc(Display.java:4070) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1977) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3018) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1914) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1878) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:419) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:95) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:104) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:74) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:348) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:165) 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.invokeFramework(Main.java:341) at org.eclipse.core.launcher.Main.basicRun(Main.java:285) at org.eclipse.core.launcher.Main.run(Main.java:987) at org.eclipse.core.launcher.Main.main(Main.java:962)

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