Project: JDT
Bug 99933 [generalize type] throws ArrayOutOfBoundsException
Reported: 2005-06-14 07:06:40 | Status: verified fixed

In RC2. SayTests.java attached, created during "real" development today. Place the cursor on variable "token" on line 122, and execute Refactor > Generalize Type. The dialog warns "Internal Error during computation of valid types", and the following is written to the log: java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:327) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.run(RefactoringWizardDialog2.java:293) at org.eclipse.jdt.internal.ui.refactoring.ChangeTypeWizard$ChangeTypeInputPage$ValidTypesTask.run(ChangeTypeWizard.java:204) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:118) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3035) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2694) at org.eclipse.jface.window.Window.runEventLoop(Window.java:809) at org.eclipse.jface.window.Window.open(Window.java:787) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation$1.run(RefactoringWizardOpenOperation.java:125) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run(RefactoringWizardOpenOperation.java:138) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:40) at org.eclipse.jdt.internal.corext.refactoring.RefactoringExecutionStarter.startChangeTypeRefactoring(RefactoringExecutionStarter.java:189) at org.eclipse.jdt.ui.actions.ChangeTypeAction.run(ChangeTypeAction.java:156) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:226) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:198) at org.eclipse.jface.action.Action.runWithEvent(Action.java:996) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:538) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:488) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:400) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:844) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3058) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2691) at org.eclipse.jdt.internal.ui.actions.QuickMenuAction.run(QuickMenuAction.java:79) at org.eclipse.jface.action.Action.runWithEvent(Action.java:996) at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:182) at org.eclipse.ui.internal.handlers.LegacyHandlerWrapper.execute(LegacyHandlerWrapper.java:108) at org.eclipse.core.commands.Command.execute(Command.java:311) at org.eclipse.core.commands.ParameterizedCommand.execute(ParameterizedCommand.java:396) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:459) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:781) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:828) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:550) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:493) at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:117) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Display.filterEvent(Display.java:910) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:868) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:853) at org.eclipse.swt.widgets.Control.traverse(Control.java:2778) at org.eclipse.swt.widgets.Control.translateMnemonic(Control.java:2619) at org.eclipse.swt.widgets.Composite.translateMnemonic(Composite.java:827) at org.eclipse.swt.widgets.Control.translateMnemonic(Control.java:2637) at org.eclipse.swt.widgets.Display.translateMnemonic(Display.java:3490) at org.eclipse.swt.widgets.Display.filterMessage(Display.java:924) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2687) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1716) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1680) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:365) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:103) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:163) 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:585) at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334) at org.eclipse.core.launcher.Main.basicRun(Main.java:278) at org.eclipse.core.launcher.Main.run(Main.java:973) at org.eclipse.core.launcher.Main.main(Main.java:948) Caused by: java.lang.ArrayIndexOutOfBoundsException: 1 at org.eclipse.jdt.internal.corext.refactoring.typeconstraints.ParameterTypeVariable.<init>(ParameterTypeVariable.java:24) at org.eclipse.jdt.internal.corext.refactoring.typeconstraints.ConstraintVariableFactory.makeParameterTypeVariable(ConstraintVariableFactory.java:177) at org.eclipse.jdt.internal.corext.refactoring.typeconstraints.FullConstraintCreator.getArgumentConstraints(FullConstraintCreator.java:543) at org.eclipse.jdt.internal.corext.refactoring.typeconstraints.FullConstraintCreator.create(FullConstraintCreator.java:290) at org.eclipse.jdt.internal.corext.refactoring.typeconstraints.ConstraintCollector.visit(ConstraintCollector.java:372) at org.eclipse.jdt.core.dom.MethodInvocation.accept0(MethodInvocation.java:236) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2520) at org.eclipse.jdt.core.dom.MethodInvocation.accept0(MethodInvocation.java:244) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450) at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2497) at org.eclipse.jdt.core.dom.ExpressionStatement.accept0(ExpressionStatement.java:143) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2520) at org.eclipse.jdt.core.dom.Block.accept0(Block.java:135) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450) at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2497) at org.eclipse.jdt.core.dom.MethodDeclaration.accept0(MethodDeclaration.java:501) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2520) at org.eclipse.jdt.core.dom.TypeDeclaration.accept0(TypeDeclaration.java:483) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2520) at org.eclipse.jdt.core.dom.CompilationUnit.accept0(CompilationUnit.java:299) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeTypeRefactoring.getConstraints(ChangeTypeRefactoring.java:1203) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeTypeRefactoring.getConstraints(ChangeTypeRefactoring.java:1171) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeTypeRefactoring.findConstraintVariableForSelectedNode(ChangeTypeRefactoring.java:903) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeTypeRefactoring.computeValidTypes(ChangeTypeRefactoring.java:418) at org.eclipse.jdt.internal.ui.refactoring.ChangeTypeWizard$1.run(ChangeTypeWizard.java:195) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:113)

Files changed in fix:
org.eclipse.jdt.ui.tests.refactoring/resources/ChangeTypeRefactoring/positive/A_testVarArg2_in.java org.eclipse.jdt.ui.tests.refactoring/resources/ChangeTypeRefactoring/positive/A_testVarArg_in.java org.eclipse.jdt.ui.tests.refactoring/resources/ChangeTypeRefactoring/positive/A_testVarArg_out.java org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ChangeTypeRefactoringTests.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ChangeTypeRefactoring.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/typeconstraints/FullConstraintCreator.java