ANT JAVAC failed with “error=87, The parameter is incorrect”

Leave a comment

March 26, 2010 by huionn

Today I encountered a weird problem, the ant build that always worked, suddenly failed with “java.io.IOException: CreateProcess error=87, The parameter is incorrect”.

Clueless… I googled and found http://mihail.stoynov.com/blog/Trackback.aspx?guid=c00763f2-ade4-4532-bd3d-0b96f5ddf7b9 which mentioned that setting forked=”false” can solve the problem.
But the root cause remains a mystery to me…

At home, I spent some times trying to dig it out and found this…

What is the command line length limit?

The maximum command line length for the CreateProcess function is 32767 characters. This limitation comes from the UNICODE_STRING structure…

It seems like the arguments passed to javac have exceeded the limit (or other limit incurred by cmd) and was truncated. I assume this is supposed to be the root cause and I cannot prove it at home…

Better solution from http://markmail.org/message/axjexqxdobjepoxl:

<tempfile property="temp.file" deleteonexit="true"/>
<concat destfile="${temp.file}">${apt.sourcepath}</concat>
<exec executable="${apt.home}/bin/apt">
<arg line="-s ${generated-source-dir}"/>
<arg line="-d ${generated-classes-dir}"/>

<arg line="@${temp.file}"/>
</exec>
<delete file="${temp.file}"/>

This solution is based on JAVAC Command Line Argument Files (http://java.sun.com/javase/6/docs/technotes/tools/windows/javac.html#commandlineargfile)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: