How to deal with "argument list too long" from infer-and-annotate.sh?

28 views
Skip to first unread message

Jo D

unread,
May 27, 2021, 2:27:27 PM5/27/21
to Checker Framework discussion
Hi all,

here's what I'm doing, and why:
PATH=target/downloads/zulu11.41.24-sa-jdk11.0.8-win_i686/bin:$PATH checker-framework-3.13.0/checker/bin/infer-and-annotate.sh GuiEffectChecker "$(echo target/lib/* | tr ' ' :)" $(find src/main/java *.java) $(find src/test/java *.java)

Output:
checker-framework-3.13.0/checker/bin/javac: line 38: target/downloads/zulu11.41.24-sa-jdk11.0.8-win_i686/bin/java: Argument list too long

Which comes as no surprise to me: that's 2315 files with a total length of 162850 filename characters, which would be too much for any shell.

How do I reduce the command-line length?
I have been considering compiling the sources into a .jar first and having an empty set of source files, but I'd likely run into the exact same problem when I try to merge the output into the .java files.
Will it work if I put the names into java-sources.txt and use @java-sources.txt on the infer-and-annotate.sh command?

Any help appreciated!
Regards,
Jo


Background details for the curious:

target/downloads/zulu11.41.24-sa-jdk11.0.8-win_i686/bin:$PATH sets the path to include the Java binaries (they're downloaded as part of a pre-existing machinery that we use because corporate setup never installs quite the Java version that we expect).
It's not an absolute path, so it's susceptible to problems if anything does a cd  command, though I don't think it's the problem here (the script thankfully reports the javac command line, and shows the right command is being run).

"$(echo target/lib/*.jar | tr ' ' :)" picks up the .jar files in the target/lib directory (blank-separated by the shell), and replaces the blanks with : characters to form a classpath. (The : may be the wrong separator since it's a Windows javac running under Cygwin, but I believe javac fails before looking at the classpath.)
I'd really have preferred to directly use javac's target/lib/* classpath syntax, but the star doesn't make it through the scripts - likely the parameter isn't properly quoted.

Jo D

unread,
May 28, 2021, 4:03:31 AM5/28/21
to Checker Framework discussion
Update: I copied the echo  commands from the wrong location. It's  $(find src/main/java  -name ' *.java') , not  $(find src/main/java *.java) .
The actual command is then:
PATH=target/downloads/zulu11.41.24-sa-jdk11.0.8-win_i686/bin:$PATH checker-framework-3.13.0/checker/bin/infer-and-annotate.sh GuiEffectChecker "$(echo target/lib/* | tr ' ' :)" $(find src/main/java -name '*.java') $(find src/test/java -name '*.java')
and I validated that it still gives me:
checker-framework-3.13.0/checker/bin/javac: line 38: target/downloads/zulu11.41.24-sa-jdk11.0.8-win_i686/bin/java: Argument list too long

Jo D

unread,
May 28, 2021, 11:35:14 AM5/28/21
to Checker Framework discussion

Another update: The scripts don't work with  @java-sources.txt  , but I could make them to work with reasonable effort.
I'm now hitting another problem (the -cp classpath is ignored); investigating.

That said: Is there interest in patches for making infer-and-annotate recognize the @java-sources.txt  syntax?
It's tested but only for my use case, i.e. it's likely incomplete. However, it could be useful as a starting point for others.

Jo D

unread,
May 28, 2021, 1:02:57 PM5/28/21
to Checker Framework discussion
Okay... I have a running system now.
I'm going to prepare PRs for script and documentation updates on Monday.

Reply all
Reply to author
Forward
0 new messages