Bug 63111 - Javac task CreateProcess Error 206 on windows
Summary: Javac task CreateProcess Error 206 on windows
Status: NEW
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: 1.9.7
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-25 04:02 UTC by Florian Bruckner
Modified: 2019-12-18 13:48 UTC (History)
0 users



Attachments
a proposed patch (7.80 KB, patch)
2019-01-26 03:48 UTC, Florian Bruckner
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Bruckner 2019-01-25 04:02:27 UTC
On Windows, CreateProcess has a limit of 32K characters for the command line. If the generated javac command line exceeds this limit, running javac fails with an error 206.

Inspecting the source responsible for creating the command line reveals that this is already a known issue and executeExternalCompile of DefaultCompilerAdapter creates an arg file for the files to be compiled in case the command line is longer.

This does not happen when another parameter (like -classpath) causes the limit to exceed. According to e.g. https://docs.oracle.com/javase/7/docs/technotes/tools/windows/javac.html#commandlineargfile any command line parameter except -J arguments can be put into an argument file.

I therefore propose to modify DefaultCompilerAdapter so it will put all command line arguments into the argument file already generated except those before the last -J parameter.
Comment 1 Florian Bruckner 2019-01-26 03:48:28 UTC
Created attachment 36394 [details]
a proposed patch
Comment 2 Florian Bruckner 2019-01-26 03:52:51 UTC
This is probably a duplicate of 50781
Comment 3 Fergal Gavin 2019-12-18 13:37:12 UTC
Hi folks,

Has anything changed internally between ANT 1.10.6 and ANT 1.10.7 with regards to the <javac> target and the limit for the associated generated command line.

We have observed within out project:

 - same location for the "ANT" installation.
 - same location for the Java source being compiled.

When we run the same build script target to compile the source for a specific directory, the build is successful using ANT 1.10.6 (and earlier versions including the 1.9.x versions) but falls over using the specific 1.10.7 version (see error below).

Any ideas on what could be causing this with regards to the possible changes introduced between those two versions of ANT?

Thanks,

Fergal.

=======================
ANT TARGET

  <target name="-compile-actions">
    <javac
      memoryMaximumSize="${cmp.maxmemory}"
      memoryInitialSize="${cmp.maxmemory}"
      fork="yes"
      srcdir="${dir.gen.actions}"
      destdir="${dir.tmp.actions}"
      debug="${debug.info}"
      includeantruntime="false"
      deprecation="${cmp.deprecation}"
      debuglevel="${debug.level}"
      classpathref="compile.cp">
      <compilerarg value="-Xbootclasspath/p:${toString:xml.cp}" />
      <compilerarg value="-Xmaxwarns"/>
      <compilerarg value="${cmp.maxwarnings}"/>
      <compilerarg line="${cmp.compilerarg}"/>
    </javac>
  </target>

=======================
Error
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:284)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:101)
Caused by: java.io.IOException: Cannot run program "C:\CC\DevEnv\7.0.10.0\tools\java\bin\javac.exe" (in directory "C:\Dev\TI_7100_2\TI\tests\TabTestApp\webclient"): CreateProcess error=206, The filename or extension is too long
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
        at java.lang.Runtime.exec(Runtime.java:620)
        at org.apache.tools.ant.taskdefs.launcher.Java13CommandLauncher.exec(Java13CommandLauncher.java:58)
        at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:424)
        at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:438)
        at org.apache.tools.ant.taskdefs.compilers.DefaultCompilerAdapter.executeExternalCompile(DefaultCompilerAdapter.java:588)
        ... 61 more
Caused by: java.io.IOException: CreateProcess error=206, The filename or extension is too long
        at java.lang.ProcessImpl.create(Native Method)
        at java.lang.ProcessImpl.<init>(ProcessImpl.java:386)
        at java.lang.ProcessImpl.start(ProcessImpl.java:137)
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
        ... 66 more
Comment 4 Jaikiran Pai 2019-12-18 13:48:05 UTC
Yes, we have had a change in this area in this recent release. However, we did fix a bug related to this in the latest (unreleased) upstream master. Is there any chance you can try our latest nightly Ant build https://builds.apache.org/job/Ant_Nightly/lastSuccessfulBuild/artifact/distribution/ and see if it's reproducible there? If it still is reproducible with the nightly build, please report back with the details, preferably in a new bugzilla issue.