Bug 23340 - [ExternalTools] ArrayIndexOutOfBounds exception when running ant in a build
Summary: [ExternalTools] ArrayIndexOutOfBounds exception when running ant in a build
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Ant (show other bugs)
Version: 2.0.1   Edit
Hardware: PC Windows 2000
: P1 normal (vote)
Target Milestone: 2.0.2   Edit
Assignee: Darin Wright CLA
QA Contact:
URL:
Whiteboard:
Keywords: ui
Depends on:
Blocks:
 
Reported: 2002-09-09 14:40 EDT by Jeff Reichenberg CLA
Modified: 2002-10-29 11:18 EST (History)
2 users (show)

See Also:


Attachments
Sample build file that causes the problem. (1.38 KB, text/plain)
2002-10-21 19:20 EDT, David Corbin CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jeff Reichenberg CLA 2002-09-09 14:40:48 EDT
I have a vanilla eclipse 2.0 installation. My project compiles java code then 
invokes an ant script with no arguments. All is well with 2.0. When I upgrade 
to 2.0.1 I get an ArrayOutOfBoundsException when I build the project. If I run 
the ant script directly it works fine. If I change the build not to run the ant 
script automatically, the build works (minus what the ant script does).

I get no output to the log window when this happens so I don't think the Ant 
script even starts. 

The message is:
Problems occurred when invoking code from plug-in:"org.eclipse.core.resources"


Here is the stack trace:

java.lang.ArrayIndexOutOfBoundsException
at org.eclipse.ui.externaltools.internal.core.AntFileRunner.execute
(AntFileRunner.java:44)
at org.eclipse.ui.externaltools.internal.core.DefaultRunnerContext.executeRunner
(DefaultRunnerContext.java:413)
at org.eclipse.ui.externaltools.internal.core.DefaultRunnerContext.run
(DefaultRunnerContext.java:439)
at org.eclipse.ui.externaltools.internal.core.ExternalToolsBuilder.build
(ExternalToolsBuilder.java:50)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:392)
at org.eclipse.core.internal.runtime.InternalPlatform.run
(InternalPlatform.java:839)
at org.eclipse.core.runtime.Platform.run(Platform.java:416)
at org.eclipse.core.internal.events.BuildManager.basicBuild
(BuildManager.java:120)
at org.eclipse.core.internal.events.BuildManager.basicBuild
(BuildManager.java:176)
at org.eclipse.core.internal.events.BuildManager.basicBuild
(BuildManager.java:186)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:146)
at org.eclipse.core.internal.runtime.InternalPlatform.run
(InternalPlatform.java:839)
at org.eclipse.core.runtime.Platform.run(Platform.java:416)
at org.eclipse.core.internal.events.BuildManager.basicBuild
(BuildManager.java:160)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:232)
at org.eclipse.core.internal.resources.Project.build(Project.java:85)
at org.eclipse.ui.actions.BuildAction.invokeOperation(BuildAction.java:151)
at org.eclipse.ui.actions.WorkspaceAction.execute(WorkspaceAction.java:112)
at org.eclipse.ui.actions.WorkspaceAction$1.execute(WorkspaceAction.java:269)
at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run
(WorkspaceModifyOperation.java:64)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1378)
at org.eclipse.ui.actions.WorkspaceModifyOperation.run
(WorkspaceModifyOperation.java:78)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run
(ModalContext.java:98)
Comment 1 David Corbin CLA 2002-10-21 19:20:37 EDT
Created attachment 2247 [details]
Sample build file that causes the problem.
Comment 2 Darin Swanson CLA 2002-10-21 20:59:26 EDT
Problem appears to have been caused by fix to bug 20797.
Comment 3 Darin Swanson CLA 2002-10-21 21:11:50 EDT
Problem currently only exists in the 2.0.* streams.
BUT the fix that caused the problem needs to be added to the 2.1 stream (bug 
22402).
Comment 4 Darin Swanson CLA 2002-10-21 21:22:33 EDT
Problem is in AntFileRunner#execute

Code is currently:
String[] newArgs = new String[args.length + 1];
for (int i=0; i < newArgs.length; i++) {
	newArgs[i] = args[i];	
}
Code should be:
String[] newArgs = new String[args.length + 1];
for (int i=0; i < newArgs.length - 1; i++) {  //CHANGE HERE
	newArgs[i] = args[i];	
}
				
Comment 5 Darin Swanson CLA 2002-10-22 12:07:45 EDT
Fixed in the 2.0.2 stream
Please verify the changes to AntFileRunner (Darin W).
Comment 6 Darin Wright CLA 2002-10-22 12:41:48 EDT
Verified.
Comment 7 David Corbin CLA 2002-10-22 13:04:59 EDT
Is there any way to tweak the build file so that this will not happen in 2.0.1?
Comment 8 Darin Swanson CLA 2002-10-29 10:18:55 EST
Sorry for the delay in response but I was no longer "attached" to this bug. 
I believe if you do not set a working directory the problem should not occur.
Comment 9 David Corbin CLA 2002-10-29 10:51:14 EST
If you don't specify a working directory, do you know what IS your working
directory?
Comment 10 Darin Swanson CLA 2002-10-29 11:18:18 EST
It would be the basedir specified in your build file.
So it should work if you correctly specify your basedir in your build file but 
do not specify the working directory in the external tools setup.