Don't use anonymous URLClassLoaders

This makes debugging a bit easier in the eclipse memory analyzer tool
since we get a more specific classloader type than URLClassLoader and by
giving the class a meaningful name, we can tell from where it
originated.
This commit is contained in:
Ethan Atkins 2019-05-25 17:45:15 -07:00
parent af9f665649
commit 468334f142
2 changed files with 7 additions and 5 deletions

View File

@ -773,7 +773,7 @@ object Defaults extends BuildCommon {
class ScalaLoader extends URLClassLoader(allJars.map(_.toURI.toURL).toArray, libraryLoader)
val fullLoader = classLoaderCache.cachedCustomClassloader(
allJars.toList,
() => new URLClassLoader(allJars.map(_.toURI.toURL).toArray, libraryLoader)
() => new ScalaLoader
)
new ScalaInstance(
version,

View File

@ -230,10 +230,12 @@ private[sbt] object ClassLoaders {
} else parent
}
private[this] class FlatLoader(classpath: Seq[File], parent: ClassLoader)
extends URLClassLoader(classpath.map(_.toURI.toURL).toArray, parent) {
override def toString: String =
s"FlatClassLoader(parent = $interfaceLoader, jars =\n${classpath.mkString("\n")}\n)"
}
// helper methods
private def flatLoader(classpath: Seq[File], parent: ClassLoader): ClassLoader =
new URLClassLoader(classpath.map(_.toURI.toURL).toArray, parent) {
override def toString: String =
s"FlatClassLoader(parent = $interfaceLoader, jars =\n${classpath.mkString("\n")}\n)"
}
new FlatLoader(classpath, parent)
}