Menu

#238 The standard classpath wildcard should not get expanded

3.x
open
nobody
None
5
2025-06-03
2025-06-03
No

If you specify in the l4j configuration as classpath lib/*, l4j expands this to all entries in the directory, including . and ...

If you give lib/* as classpath entry to the Java process, this means "all jars in that directory".

IF the filename only consists of the standard Java wildcard *, this should not get expanded, but forwarded as-is to the Java process.

Besides being unexpected as it puts things on the classpath it shouldn't put there, this also has a practical consequence. With non-exe means to start an application, like a batch script, it happens that the commandline becomes too long for Windows if you list each jar manually, which can be prevented by either using an @-file if the JRE supports it, or by using the wildcard if you don't depend on the classpath order which is bad anyway.

I don't know whether l4j has measures for too long command lines like using an @-file or similar, or whether it does anyway not have that problem no matter how long the commanline becomes, but it imho is wrong to expand this standard-wildcard.

The work-around to get expected behavior is to use .../*.jar instead of .../* as long as the length limit does not get hit.

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.