You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Nico Seessle <ni...@seessle.de> on 2000/09/17 10:55:40 UTC

[PATCH] Javac.java - Problems running javac on Windows

With JDK < 1.3 there seem to be some problem executing javac-processes
(using jikes) which will work with JDK 1.3. Ouput indicates "The following
character string is too long", so there seems to be a different behaviour in
command line handling. Tested with JDK 1.1.7 (IBM), JDK 1.1.7A (Visual Cafe
3.0), JDK 1.2, JDK 1.2.2 and JDK 1.3 (even with JView 5.0.3229) on W2K.

Is it OK to post patches like this? (Regarding the format that may be
resulting from pasting this to Outlook Express).

Index: Javac.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Javac.jav
a,v
retrieving revision 1.39
diff -u -r1.39 Javac.java
--- Javac.java 2000/09/15 07:10:58 1.39
+++ Javac.java 2000/09/17 08:48:41
@@ -680,9 +680,12 @@
             // create a temporary file to store all the arguments

             // There have been reports that 300 files could be compiled
-            // so 250 is a conservative approach
+            // so 250 is a conservative approach, except on JDK < 1.3
+            // where this fails for mysterious reasons, so let's be extra
safe.
             if (myos.toLowerCase().indexOf("windows") >= 0
-                && args.length > 250) {
+                && (args.length > 250 ||
+                    Project.getJavaVersion().equals(Project.JAVA_1_1) ||
+                    Project.getJavaVersion().equals(Project.JAVA_1_2) ) ) {
                 PrintWriter out = null;
                 try {
                     tmpFile = new File("jikes"+(new
Random(System.currentTimeMillis())).nextLong());




Re: [PATCH] Javac.java - Problems running javac on Windows

Posted by Nico Seessle <ni...@seessle.de>.
----- Original Message -----
From: "Stefan Bodewig" <bo...@bost.de>
To: <an...@jakarta.apache.org>
Sent: Tuesday, September 19, 2000 10:30 AM
Subject: Re: [PATCH] Javac.java - Problems running javac on Windows


> >>>>> "DW" == Dirk Weigenand <Di...@oracle.com> writes:
>  DW> Is it really necessary to bind the trigger to the number of
>  DW> arguments rahter to the combined length of them?
>
> It depends.
>
> We first found that Runtime.exec() is going to fail on Windows at
> about 300 elements in the args array. If we want to restrict the
> trigger to depend on the length of the command line this would have to
> be rather short (as 300 times A.java would already be too long).
>

I don't know who found this, but I don't think this was a problem with the
number of arguments. I did some research and here are the figures:

On Windows (98SE, NT4.0 SP6a and W2K SP0) the max. length of command line
was 32k for me if the command is executed directly thru exec() (or whatever
the JVM is using in Runtime....exec()). If a changedir is required (and Ant
uses cmd.exe for this) the Limit is going down to about 4000 Bytes. It's no
problem to feed all of these with an exec-command which uses 6000 Arguments
(also these must be really short :-) ).

On AIX 4.3 using JDK 1.1.6 the limit seems to be a length of about 24k
(subtract your environment space) or a max. of of about 5800 arguments.

On Linux the maximum is (as Stefan already wrote) above 100k (127000 was the
largest I tried) or 31201 arguments.

The POSIX limit seems to be 4096 Bytes (limits.h on AIX 4.3 states something
like this).

So in general the number of arguments seems not to be a real problem,
problems just rise if these arguments are very long and the total length of
arg-space is exceeded.

I don't know what we could do for UNIX, to be really safe it would be a
possible solution to set the Limit to 4096, inspect the properties of the VM
and if it's known that the current OS can handle larger numbers use them.

Don't know if Novell and/or AS/400 also include javac and/or if ant
would/should be used on these?

Nico



Re: [PATCH] Javac.java - Problems running javac on Windows

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "DW" == Dirk Weigenand <Di...@oracle.com> writes:

 DW> So the approach could be to cut this prefix off the filename and
 DW> use a relative filename to shorten the overall command line.

In some cases yes, but not generally. We don't force the location
where your sources live, the location of build.xml and the CWD of the
shell where you invoke Ant from to have any realtion at all.

 DW> Is it really necessary to bind the trigger to the number of
 DW> arguments rahter to the combined length of them?

It depends. 

We first found that Runtime.exec() is going to fail on Windows at
about 300 elements in the args array. If we want to restrict the
trigger to depend on the length of the command line this would have to
be rather short (as 300 times A.java would already be too long).

Stefan

Re: [PATCH] Javac.java - Problems running javac on Windows

Posted by Dirk Weigenand <Di...@oracle.com>.
Hi,

Stefan Bodewig wrote:
> 
> >>>>> "DW" == Dirk Weigenand <Di...@oracle.com> writes:
> 
>  DW> I haven't looked into the issue very deeply but my feeling is
>  DW> that doJikesCompile should be extended to check the length of the
>  DW> resulting command line and if it exceeds some limit to take the
>  DW> same approach as on Windows XX
> 
> Probably, yes.
> 
> For Linux there is a limit in /usr/include/linux/limits.h:
> 
> #define ARG_MAX       131072    /* # bytes of args + environ for exec() */
> 
> (Kernel 2.2).
> 
> I think POSIX defines a limit for the length of command lines but
> can't remember the details.
> 
> If 1000 files get Jikes into trouble than the filenames must be quite
> long I guess - or carry around a huge environment. Any idea what we
> should take as a limit? 100kByte?
> 
> As for the related problem on Win98 - I'd like to investigate this one
> further before we create temporary files for each and every Jikes
> compile on earth.
> 
> Usually we don't get into trouble with the length of the command
> line. Diane, are you using a very deep directory structure so that the
> filenames themselves get very long?
> 

Under Linux the filenames get indeed very long since the directory where
the project is situated sits rather deep in the directory structure, i.e.
each java source gets prefixed with
/home/weigo/java/classes/basis/entwicklung/source.

So the approach could be to cut this prefix off the filename and use a
relative
filename to shorten the overall command line.

Comments?

> Maybe we could fix both problems with a single patch, something like
> "if running on Windows and the number of files is > 250 or the total
> command line is longer than (as DOS systems are involved) 64k" to
> trigger the temporary file approach?
> 

Is it really necessary to bind the trigger to the number of arguments rahter
to the combined length of them? I think the problem is bound to the size of
the
environment and not to the number of arguments (at least not directly since it
should be bounded by the size of the environment anyway?).

> Stefan

Regards,
	Dirk
-- 
Daddy, what does "format disk c: complete" mean?
Who is General Failure and why is he reading my disk?

Re: [PATCH] Javac.java - Problems running javac on Windows

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "DW" == Dirk Weigenand <Di...@oracle.com> writes:

 DW> I haven't looked into the issue very deeply but my feeling is
 DW> that doJikesCompile should be extended to check the length of the
 DW> resulting command line and if it exceeds some limit to take the
 DW> same approach as on Windows XX

Probably, yes.

For Linux there is a limit in /usr/include/linux/limits.h:

#define ARG_MAX       131072	/* # bytes of args + environ for exec() */

(Kernel 2.2).

I think POSIX defines a limit for the length of command lines but
can't remember the details.

If 1000 files get Jikes into trouble than the filenames must be quite
long I guess - or carry around a huge environment. Any idea what we
should take as a limit? 100kByte?

As for the related problem on Win98 - I'd like to investigate this one
further before we create temporary files for each and every Jikes
compile on earth. 

Usually we don't get into trouble with the length of the command
line. Diane, are you using a very deep directory structure so that the
filenames themselves get very long? 

Maybe we could fix both problems with a single patch, something like
"if running on Windows and the number of files is > 250 or the total
command line is longer than (as DOS systems are involved) 64k" to
trigger the temporary file approach?

Stefan

Re: [PATCH] Javac.java - Problems running javac on Windows

Posted by Dirk Weigenand <Di...@oracle.com>.
Hi,

Nico Seessle wrote:
> 
> ----- Original Message -----
> From: "Michael McCallum" <mi...@spinsoftware.co.nz>
> To: <an...@jakarta.apache.org>
> Sent: Monday, September 18, 2000 6:05 AM
> Subject: Re: [PATCH] Javac.java - Problems running javac on Windows
> 
> > I have had this problem on linux as well when compiling > 1000 classes
> with relatively long
> > paths.
> >
> 

Me too trying to compile 1700+ classes with jikes. I haven't looked into the
issue very deeply but my feeling is that doJikesCompile should be extended
to check the length of the resulting command line and if it exceeds some limit
to take the same approach as on Windows XX and dump the list of files to
compile
to a file and continue with this as input to the compiler. The problem doesn't 
occur when doing a modern compile (ibm's jdk 1.3 for me).

> Since I can't test this (no Linux currently, still trying to find a "good"
> distribution which runs Oracle 8i out of the box :-) (oh, and waiting for
> 8ir2...)) I can not change this, someone else?
> 
Have a look at Debian, at least that's what i'm running 8.1.6 on. Basically
every distribution using glibc 2.1 should suffice.

> I hope on Linux it should be at least possible to get a proper documentation
> on how long a command line (or how many arguments) can be..
> 
> Nico

Regards,
	Dirk
-- 
Daddy, what does "format disk c: complete" mean?
Who is General Failure and why is he reading my disk?

Re: [PATCH] Javac.java - Problems running javac on Windows

Posted by Nico Seessle <ni...@seessle.de>.
----- Original Message -----
From: "Michael McCallum" <mi...@spinsoftware.co.nz>
To: <an...@jakarta.apache.org>
Sent: Monday, September 18, 2000 6:05 AM
Subject: Re: [PATCH] Javac.java - Problems running javac on Windows


> I have had this problem on linux as well when compiling > 1000 classes
with relatively long
> paths.
>

Since I can't test this (no Linux currently, still trying to find a "good"
distribution which runs Oracle 8i out of the box :-) (oh, and waiting for
8ir2...)) I can not change this, someone else?

I hope on Linux it should be at least possible to get a proper documentation
on how long a command line (or how many arguments) can be..

Nico


Re: [PATCH] Javac.java - Problems running javac on Windows

Posted by Michael McCallum <mi...@spinsoftware.co.nz>.
I have had this problem on linux as well when compiling > 1000 classes with relatively long 
paths.


--- BEGIN GEEK CODE BLOCK ---
Version 3.12
GCS d+(-) s:- a-- C++(+++)$ UL++++(H)(S)$ P+++$ L+++$>++++
E--- W++ N++ o++ K? !w() O? !M V? PS+ PE+++ Y+ t+ 5++ X++ 
R(+) !tv b++(++++) D++ G>++ e++> h--()(*) r+ y+()
--- END GEEK CODE BLOCK ---