Skip to content

Commit

Permalink
fix classpath handling in staging [test-only]
Browse files Browse the repository at this point in the history
  • Loading branch information
liufengyun committed Aug 6, 2020
1 parent 11560cb commit 8aa7f6b
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions compiler/src/dotty/tools/dotc/util/ClasspathFromClassloader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,26 @@ 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`.
// See: https://java-browser.yawk.at/java/10/java.base/jdk/internal/loader/ClassLoaders.java#163
classpathBuff += System.getProperty("java.class.path")
}
}
}
collectClassLoaderPaths(cl)
classpathBuff.result().mkString(java.io.File.pathSeparator)
}
}
}

0 comments on commit 8aa7f6b

Please sign in to comment.