Skip to content

Fix #9500: Use java.class.path for Java 9+ class loaders #9506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 6, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions compiler/src/dotty/tools/dotc/util/ClasspathFromClassloader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,21 @@ object ClasspathFromClassloader {
classpathBuff ++=
cl.getURLs.iterator.map(url => Paths.get(url.toURI).toAbsolutePath.toString)
case _ =>
// HACK: We can't just collect the classpath from arbitrary parent
// classloaders since the current classloader might intentionally
// filter loading classes from its parent (for example
// BootFilteredLoader in the sbt launcher does this and we really
// don't want to include the scala-library that sbt depends on
// here), but we do need to look at the parent of the REPL
// classloader, so we special case it. We can't do this using a type
// test since the REPL classloader class itself is normally loaded
// with a different classloader.
if (cl.getClass.getName == classOf[AbstractFileClassLoader].getName)
if cl.getClass.getName == classOf[AbstractFileClassLoader].getName then
// HACK: We can't just collect the classpath from arbitrary parent
// classloaders since the current classloader might intentionally
// filter loading classes from its parent (for example
// BootFilteredLoader in the sbt launcher does this and we really
// don't want to include the scala-library that sbt depends on
// here), but we do need to look at the parent of the REPL
// classloader, so we special case it. We can't do this using a type
// test since the REPL classloader class itself is normally loaded
// with a different classloader.
collectClassLoaderPaths(cl.getParent)
else if cl eq ClassLoader.getSystemClassLoader then
// HACK: For Java 9+, if the classloader is an AppClassLoader then use the classpath from the system
// property `java.class.path`.
classpathBuff += System.getProperty("java.class.path")
}
}
}
Expand Down