Skip to content

Commit 8aa7f6b

Browse files
committed
fix classpath handling in staging [test-only]
1 parent 11560cb commit 8aa7f6b

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

compiler/src/dotty/tools/dotc/util/ClasspathFromClassloader.scala

+16-11
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,26 @@ object ClasspathFromClassloader {
2727
classpathBuff ++=
2828
cl.getURLs.iterator.map(url => Paths.get(url.toURI).toAbsolutePath.toString)
2929
case _ =>
30-
// HACK: We can't just collect the classpath from arbitrary parent
31-
// classloaders since the current classloader might intentionally
32-
// filter loading classes from its parent (for example
33-
// BootFilteredLoader in the sbt launcher does this and we really
34-
// don't want to include the scala-library that sbt depends on
35-
// here), but we do need to look at the parent of the REPL
36-
// classloader, so we special case it. We can't do this using a type
37-
// test since the REPL classloader class itself is normally loaded
38-
// with a different classloader.
39-
if (cl.getClass.getName == classOf[AbstractFileClassLoader].getName)
30+
if cl.getClass.getName == classOf[AbstractFileClassLoader].getName then
31+
// HACK: We can't just collect the classpath from arbitrary parent
32+
// classloaders since the current classloader might intentionally
33+
// filter loading classes from its parent (for example
34+
// BootFilteredLoader in the sbt launcher does this and we really
35+
// don't want to include the scala-library that sbt depends on
36+
// here), but we do need to look at the parent of the REPL
37+
// classloader, so we special case it. We can't do this using a type
38+
// test since the REPL classloader class itself is normally loaded
39+
// with a different classloader.
4040
collectClassLoaderPaths(cl.getParent)
41+
else if cl eq ClassLoader.getSystemClassLoader then
42+
// HACK: For Java 9+, if the classloader is an AppClassLoader then use the classpath from the system
43+
// property `java.class.path`.
44+
// See: https://java-browser.yawk.at/java/10/java.base/jdk/internal/loader/ClassLoaders.java#163
45+
classpathBuff += System.getProperty("java.class.path")
4146
}
4247
}
4348
}
4449
collectClassLoaderPaths(cl)
4550
classpathBuff.result().mkString(java.io.File.pathSeparator)
4651
}
47-
}
52+
}

0 commit comments

Comments
 (0)