Description
Minimized code
java -Xmx20480m -Dnet.ipv6.bindv6only=0 -Dfile.encoding=UTF-8 -classpath "%CP%" -Dscala.usejavacp=true dotty.tools.dotc.Main -classpath 'c:/opt/uejlib2.13/*' c:/opt/ue/jsrc/s3.sc
Output (click arrow to expand)
Exception in thread "main" java.nio.file.InvalidPathException: Illegal char <*> at index 18: c:/opt/uejlib2.13/*
at java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92)
at java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:229)
at java.base/java.nio.file.Path.of(Path.java:147)
at java.base/java.nio.file.Paths.get(Paths.java:69)
at dotty.tools.dotc.core.MacroClassLoader$.$anonfun$1(MacroClassLoader.scala:23)
at scala.collection.ArrayOps$.map$extension(ArrayOps.scala:924)
at dotty.tools.dotc.core.MacroClassLoader$.makeMacroClassLoader(MacroClassLoader.scala:23)
at dotty.tools.dotc.core.MacroClassLoader$.init(MacroClassLoader.scala:20)
at dotty.tools.dotc.Driver.setup(Driver.scala:72)
at dotty.tools.dotc.Driver.process(Driver.scala:192)
at dotty.tools.dotc.Driver.process(Driver.scala:162)
at dotty.tools.dotc.Driver.process(Driver.scala:174)
at dotty.tools.dotc.Driver.main(Driver.scala:201)
at dotty.tools.dotc.Main.main(Main.scala)
Use of wildcards in the classpath has been supported by java since java 6. See stack overflow: including-all-the-jars-in-a-directory-within-the-java-classpath
It has also been supported at least since scala 2.8, and is critical for working around OS command line length limitations.
The current implementation assumes that every classpath entry is a file, leading to a compiler crash when the glob entry is encountered.
An alternative way to avoid long classpath problems has been available since java 9+, and is described here (see @raman's entry):
stackoverflow: using an argument file to pass classpath entries
Briefly, it the classpath is specified in a text file (e.g., cparg), which is passed to java like so:
java @c:\path\to\cparg
A similar approach could be implemented in dotty.tools.dotc.Main.main, although ideally it would allow an os-independent format, not requiring the use of path separators (e.g., one classpath entry per line).