@@ -87,6 +87,20 @@ object MainGenericCompiler {
8787
8888 val classpathSeparator : String = File .pathSeparator
8989
90+ def processClasspath (cp : String , tail : List [String ]): (List [String ], List [String ]) =
91+ val cpEntries = cp.split(classpathSeparator).toList
92+ val singleEntryClasspath : Boolean = cpEntries.take(2 ).size == 1
93+ val globdir : String = if singleEntryClasspath then cp.replaceAll(" [\\\\ /][^\\\\ /]*$" , " " ) else " " // slash/backslash agnostic
94+ def validGlobbedJar (s : String ): Boolean = s.startsWith(globdir) && ((s.toLowerCase.endsWith(" .jar" ) || s.toLowerCase.endsWith(" .zip" )))
95+ if singleEntryClasspath && validGlobbedJar(cpEntries.head) then
96+ // reassemble globbed wildcard classpath
97+ // globdir is wildcard directory for globbed jar files, reconstruct the intended classpath
98+ val cpJars = tail.takeWhile( f => validGlobbedJar(f) )
99+ val remainingArgs = tail.drop(cpJars.size)
100+ (remainingArgs, cpEntries ++ cpJars)
101+ else
102+ (tail, cpEntries)
103+
90104 @ sharable val javaOption = raw """ -J(.*) """ .r
91105 @ sharable val javaPropOption = raw """ -D(.+?)=(.?) """ .r
92106 @ tailrec
@@ -122,11 +136,10 @@ object MainGenericCompiler {
122136 case " -with-compiler" :: tail =>
123137 process(tail, settings.withCompiler)
124138 case (" -cp" | " -classpath" | " --class-path" ) :: cp :: tail =>
125- val (tailargs, newEntries) = MainGenericRunner . processClasspath(cp, tail)
139+ val (tailargs, newEntries) = processClasspath(cp, tail)
126140 process(tailargs, settings.copy(classPath = settings.classPath ++ newEntries.filter(_.nonEmpty)))
127141 case " -Oshort" :: tail =>
128142 // Nothing is to be done here. Request that the user adds the relevant flags manually.
129- // i.e this has no effect when MainGenericRunner is invoked programatically.
130143 val addTC = " -XX:+TieredCompilation"
131144 val tStopAtLvl = " -XX:TieredStopAtLevel=1"
132145 println(s " ignoring deprecated -Oshort flag, please add `-J $addTC` and `-J $tStopAtLvl` flags manually " )
0 commit comments