Fix dotty plugin

The dotty sbt-bridge module assumes that it's going to get a
URLClassLoader from which it can extract all of the classpath urls. That
doesn't work with the old wrapped classloader because its classpath was
empty. As a nasty workaround, I override the getURLs method, which is
where it gets the URLs from. After this change the
compiler-project/dotty-compiler-plugin test passes.
This commit is contained in:
Ethan Atkins 2019-05-26 19:47:55 -07:00
parent 92992a8243
commit 5f94252ff8
1 changed files with 7 additions and 1 deletions

View File

@ -3,7 +3,7 @@ package sbt.internal.classpath
import java.io.File
import java.lang.management.ManagementFactory
import java.lang.ref.{ Reference, ReferenceQueue, SoftReference }
import java.net.URLClassLoader
import java.net.{ URL, URLClassLoader }
import java.util.concurrent.atomic.AtomicInteger
import sbt.internal.inc.classpath.{
@ -107,7 +107,13 @@ private[sbt] class ClassLoaderCache(
else ClassLoaderReference.apply
private[this] val cleanupThread = new CleanupThread(ClassLoaderCache.threadID.getAndIncrement())
private[this] val lock = new Object
private class WrappedLoader(parent: ClassLoader) extends URLClassLoader(Array.empty, parent) {
// This is to make dotty work which extracts the URLs from the loader
override def getURLs: Array[URL] = parent match {
case u: URLClassLoader => u.getURLs
case _ => Array.empty
}
override def toString: String = s"WrappedLoader($parent)"
}
private def close(classLoader: ClassLoader): Unit = classLoader match {