Bug 66641 ArrayIndexOutOfBoundsExceptio when generating delegate methods
java version "1.4.2" J9 - VM for the Java(TM) platform (build 2.1) IBM J9SE VM (build 2.1, J2RE 1.4.2 IBM J9 build 20040519 (JIT enabled)) !SESSION Jun 11, 2004 11:24:48.352 --------------------------------------------- eclipse.buildId=I200406110010 java.fullversion=J2RE 1.4.2 IBM J9 build 20040519 (JIT enabled) BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US Command-line arguments: -showlocation !ENTRY org.eclipse.ui 4 4 Jun 11, 2004 11:24:48.352 !MESSAGE Unhandled event loop exception Unhandled event loop exception Reason: !ENTRY org.eclipse.ui 4 0 Jun 11, 2004 11:24:48.372 !MESSAGE java.lang.ArrayIndexOutOfBoundsException !STACK 0 java.lang.ArrayIndexOutOfBoundsException at java.lang.Throwable.<init>(Throwable.java) at java.lang.Throwable.<init>(Throwable.java) at java.lang.ArrayIndexOutOfBoundsException.<init>(ArrayIndexOutOfBounds Exception.java) at org.eclipse.jdt.ui.actions.AddDelegateMethodsAction.showUI(AddDelegat eMethodsAction.java:364) at org.eclipse.jdt.ui.actions.AddDelegateMethodsAction.run(AddDelegateMe thodsAction.java:259) at org.eclipse.jdt.ui.actions.AddDelegateMethodsAction.run(AddDelegateMe thodsAction.java:289) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(Select ionDispatchAction.java:216) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispa tchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:915) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContri butionItem.java:866) at org.eclipse.jface.action.ActionContributionItem$7.handleEvent(ActionC ontributionItem.java:785) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1362) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1333) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.jav a:252) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:141) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:96 ) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformAct ivator.java:334) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.ja va:272) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.ja va:128) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:85) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:58) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:60) at java.lang.reflect.Method.invoke(Method.java:391) at org.eclipse.core.launcher.Main.basicRun(Main.java:185) at org.eclipse.core.launcher.Main.run(Main.java:638) at org.eclipse.core.launcher.Main.main(Main.java:622) java.lang.ArrayIndexOutOfBoundsException Scenario: 1) create the class "Test123" in the default package 2) replace the content of the CU with the following text and save: /** * @author dbaeumer * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */ public class Dummy extends TestCase { private String fValue; public void testOne() throws Exception { } } 3) place the cursor on fValue. 4) From the context menu, select Source->Generate Delegate Methods 5) Observe: you get the exception.
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/AddDelegateMethodsAction.java
JavaPlugin.log(e);
						return null;
					}
					res[i] = fld;
				} else {
					return null;
				}
			}
			return res;
		}
		return null;
	}
	private void run(IType type, IField[] preselected, boolean editor) throws CoreException {
		if (!ElementValidator.check(type, getShell(), DIALOG_TITLE, editor))
			return;
		if (!ActionUtil.isProcessable(getShell(), type))
			return;
		if(!canRunOn(type)){
			MessageDialog.openInformation(getShell(), DIALOG_TITLE, ActionMessages.getString("AddDelegateMethodsAction.not_applicable")); 
			return;
		}			
		showUI(type, preselected);
	}
	
	/* (non-Javadoc)
	 * Method declared on SelectionDispatchAction
	 */
	public void selectionChanged(ITextSelection selection) {
	}
	/* (non-Javadoc)