Menu

Ant, command line size and auxClasspath

Help
C.Trauma
2008-03-24
2013-02-05
  • C.Trauma

    C.Trauma - 2008-03-24

    I'm using the ant task for FindBugs on Windows XP SP2, and I'm running to problems with windows command line size, from what I understand the limitations are:

    "The maximum command line length for the CreateProcess function is 32767 characters. This limitation comes from the UNICODE_STRING structure in Windows runtime.

    If you are using the CMD.EXE command processor, then you are also subject to the 8192 character command line length limit imposed by CMD.EXE for XP and Server 2003.

    If you are using the ShellExecute/Ex function, then you become subject to the INTERNET_MAX_URL_LENGTH (around 2048) command line length
    limit imposed by the ShellExecute/Ex functions. (If you are running on Windows 95, then the limit is only MAX_PATH (260) .)

    The maximum size of your environment is 32767 characters. The size of the environment includes all the variable names plus all the values."

    If you get a big enough classpath ( which I almost always do ), ant can't fork the VM to run FindBugs and you get an exception.

    It would be great to be able to load the classpath that FindBugs searches to resolve classes from a file instead of passing the entire string on the command line. This may be a limitation based on java itself and not on FindBugs.

    I have a custom ant task that trims and de-dupes a classpath, but with all the dependencies, packages names, and nested directories, there are still far too many characters.

    Is there an easy way to do this, or am I coming at this from the wrong direction. The same problem exists for javadoc, which also requires the classpath to be passed on the command line.. A task parameter to load the classpath from a file would be ideal..
     

     
    • C.Trauma

      C.Trauma - 2008-03-24

      The info about CreateProcess was taken from this blog post: http://blogs.msdn.com/oldnewthing/archive/2003/12/10/56028.aspx

       
    • C.Trauma

      C.Trauma - 2008-04-03

      The solution to this problem is to create a class that gets an instance of the system URLClassloader and adds the paths to that and then loads the findbugs2 target class. This can be injected into the forking process by passing it in as a jvmarg param to the task, but you also have to use -D in the jvmargs to set the property findbugs.home to make sure it happens at the right place on the command line.

       
    • C.Trauma

      C.Trauma - 2008-04-15

      I take that back.. That method works fine for loading a classpath from a file, but looking at lookupResource in ClassPathImpl it looks like only the current working set of classes being analyzed and anything being passed in on -auxClasspath are candidates for lookup. So I am back to the same problem of my process command line being two big and I have to consider modifying FindBugs source to allow reading in the classpath from a file, something like changing -auxClasspath to accept a @filenam arg...

       

Log in to post a comment.