ASF Bugzilla – Attachment 36394 Details for
Bug 63111
Javac task CreateProcess Error 206 on windows
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
a proposed patch
63111.patch (text/plain), 7.80 KB, created by
Florian Bruckner
on 2019-01-26 03:48:28 UTC
(
hide
)
Description:
a proposed patch
Filename:
MIME Type:
Creator:
Florian Bruckner
Created:
2019-01-26 03:48:28 UTC
Size:
7.80 KB
patch
obsolete
>diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java b/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java >index 9577632..7c9d8f5 100644 >--- a/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java >+++ b/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java >@@ -509,14 +509,15 @@ public abstract class DefaultCompilerAdapter > /** > * Do the compile with the specified arguments. > * @param args - arguments to pass to process on command line >- * @param firstFileName - index of the first source file in args, >+ * @param firstArgFileArgument - index of the first argument that comes, >+ * after the latest -J parameter in the arguments list. > * if the index is negative, no temporary file will ever be > * created, but this may hit the command line length limit on your > * system. > * @return the exit code of the compilation > */ >- protected int executeExternalCompile(final String[] args, final int firstFileName) { >- return executeExternalCompile(args, firstFileName, true); >+ protected int executeExternalCompile(final String[] args, final int firstArgFileArgument) { >+ return executeExternalCompile(args, firstArgFileArgument, true); > } > > /** >@@ -526,7 +527,8 @@ public abstract class DefaultCompilerAdapter > * project's base directory.</p> > * > * @param args - arguments to pass to process on command line >- * @param firstFileName - index of the first source file in args, >+ * @param firstArgFileArgument - index of the argument that comes >+ * after the last -J parameter in the arguments list. > * if the index is negative, no temporary file will ever be > * created, but this may hit the command line length limit on your > * system. >@@ -538,7 +540,7 @@ public abstract class DefaultCompilerAdapter > * > * @since Ant 1.6 > */ >- protected int executeExternalCompile(final String[] args, final int firstFileName, >+ protected int executeExternalCompile(final String[] args, final int firstArgFileArgument, > final boolean quoteFiles) { > String[] commandArray = null; > File tmpFile = null; >@@ -552,13 +554,13 @@ public abstract class DefaultCompilerAdapter > * file if the total length of the command line exceeds this limit. > */ > if (Commandline.toString(args).length() > COMMAND_LINE_LIMIT >- && firstFileName >= 0) { >+ && firstArgFileArgument >= 0) { > BufferedWriter out = null; > try { > tmpFile = FILE_UTILS.createTempFile( > "files", "", getJavac().getTempdir(), true, true); > out = new BufferedWriter(new FileWriter(tmpFile)); >- for (int i = firstFileName; i < args.length; i++) { >+ for (int i = firstArgFileArgument; i < args.length; i++) { > if (quoteFiles && args[i].contains(" ")) { > args[i] = args[i].replace(File.separatorChar, '/'); > out.write("\"" + args[i] + "\""); >@@ -568,9 +570,9 @@ public abstract class DefaultCompilerAdapter > out.newLine(); > } > out.flush(); >- commandArray = new String[firstFileName + 1]; >- System.arraycopy(args, 0, commandArray, 0, firstFileName); >- commandArray[firstFileName] = "@" + tmpFile; >+ commandArray = new String[firstArgFileArgument + 1]; >+ System.arraycopy(args, 0, commandArray, 0, firstArgFileArgument); >+ commandArray[firstArgFileArgument] = "@" + tmpFile; > } catch (final IOException e) { > throw new BuildException("Error creating temporary file", > e, location); >@@ -847,4 +849,3 @@ public abstract class DefaultCompilerAdapter > return (source.equals("1.1") || source.equals("1.2")) ? "1.3" : source; > } > } >- >diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/JavacExternal.java b/src/main/org/apache/tools/ant/taskdefs/compilers/JavacExternal.java >index e227ecf..0d7723a 100644 >--- a/src/main/org/apache/tools/ant/taskdefs/compilers/JavacExternal.java >+++ b/src/main/org/apache/tools/ant/taskdefs/compilers/JavacExternal.java >@@ -50,16 +50,41 @@ public class JavacExternal extends DefaultCompilerAdapter { > } else { > setupJavacCommandlineSwitches(cmd, true); > } >- int firstFileName = assumeJava11() ? -1 : cmd.size(); >+ int firstArgFileArgument; >+ if (assumeJava11()) { >+ firstArgFileArgument = -1; >+ } else { >+ // 63111: command lines have a size limit. When this limit >+ // is exceeded, the operating system refuses to start javac. >+ // Javac supports passing argument files for all arguments >+ // except -J arguments (which are passed to the underlying >+ // JVM. Therefore, find out where the last "-J" parameter >+ // in the command line is and allow all subsequent parameters >+ // to be put into the argfile. >+ // As the command line as used by DefaultCompilerAdapter >+ // includes the command to run, we start with at least 1. >+ firstArgFileArgument = 1; >+ for (int i = 0; i < cmd.getArguments().length; i++) { >+ if (cmd.getArguments()[i].startsWith("-J")) { >+ // The first argument as processed by DefaultCompilerAdapter >+ // is the command to run, so offset by 1. This is the latest >+ // -J parameter in the argument list, so the next argument >+ // could be placed into the argument file, if there are no >+ // additional -J arguments. >+ firstArgFileArgument = i+2; >+ } >+ } >+ attributes.log("fist potential argument file argument is on index " + firstArgFileArgument, Project.MSG_VERBOSE); >+ } > logAndAddFilesToCompile(cmd); > //On VMS platform, we need to create a special java options file > //containing the arguments and classpath for the javac command. > //The special file is supported by the "-V" switch on the VMS JVM. > if (Os.isFamily("openvms")) { >- return execOnVMS(cmd, firstFileName); >+ return execOnVMS(cmd, firstArgFileArgument); > } > return >- executeExternalCompile(cmd.getCommandline(), firstFileName, >+ executeExternalCompile(cmd.getCommandline(), firstArgFileArgument, > true) > == 0; > } >@@ -67,10 +92,10 @@ public class JavacExternal extends DefaultCompilerAdapter { > /** > * helper method to execute our command on VMS. > * @param cmd Commandline >- * @param firstFileName int >+ * @param firstArgFileArgument int > * @return boolean > */ >- private boolean execOnVMS(Commandline cmd, int firstFileName) { >+ private boolean execOnVMS(Commandline cmd, int firstArgFileArgument) { > File vmsFile = null; > try { > vmsFile = JavaEnvUtils.createVmsJavaOptionFile(cmd.getArguments()); >@@ -78,7 +103,7 @@ public class JavacExternal extends DefaultCompilerAdapter { > "-V", > vmsFile.getPath()}; > return 0 == executeExternalCompile(commandLine, >- firstFileName, >+ firstArgFileArgument, > true); > > } catch (IOException e) { >@@ -89,4 +114,3 @@ public class JavacExternal extends DefaultCompilerAdapter { > } > > } >-
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 63111
: 36394