Skip to content

Commit 1279286

Browse files
authored
Fix for #22461 Empty ClassPath attribute in one or more classpath jars causes crash (#22462)
Change to how an empty or `null` jar manifest `ClassPath:` property is handled: in dotty.tools.dotc.classpath.ClassPathFactory: - `classesInExpandedPath(...)` returns and empty `IndexedSeq` rather than crash - `isJarOrZip` returns `false` on a `null` reference rather than crash in dotty.tools.dotc.classpath.FileUtils: - `createSourcePath` fails with an error message on a `null` file parameter. In the context of #22461, this causes an empty `ClassPath:` property to be treated the same as a mispelled or missing classpath entry, which are silently ignored, matching the behaviour of legacy scripts. Closes #22461
2 parents 68b4914 + 01fc715 commit 1279286

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: compiler/src/dotty/tools/io/Jar.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class Jar(file: File) {
5050
def mainClass: Option[String] = manifest.map(_(Name.MAIN_CLASS))
5151
/** The manifest-defined classpath String if available. */
5252
def classPathString: Option[String] =
53-
for (m <- manifest ; cp <- m.attrs.get(Name.CLASS_PATH)) yield cp
53+
for (m <- manifest ; cp <- m.attrs.get(Name.CLASS_PATH) if !cp.trim().isEmpty()) yield cp
5454
def classPathElements: List[String] = classPathString match {
5555
case Some(s) => s.split("\\s+").toList
5656
case _ => Nil

0 commit comments

Comments
 (0)