@@ -8,13 +8,9 @@ import sbt.librarymanagement.{
88 VersionNumber
99}
1010import sbt .internal .inc .ScalaInstance
11- import sbt .internal .inc .classpath .ClassLoaderCache
1211import xsbti .compile ._
13- import xsbti .AppConfiguration
1412import java .net .URLClassLoader
1513import java .util .Optional
16- import java .util .{Enumeration , Collections }
17- import java .net .URL
1814import scala .util .Properties .isJavaAtLeast
1915
2016
@@ -539,27 +535,30 @@ object DottyPlugin extends AutoPlugin {
539535 scalaLibraryJar,
540536 dottyLibraryJar,
541537 compilerJar,
542- allJars,
543- appConfiguration.value
538+ allJars
544539 )
545540 }
546541
547542 // Adapted from private mkScalaInstance in sbt
548543 def makeScalaInstance (
549- state : State , dottyVersion : String , scalaLibrary : File , dottyLibrary : File , compiler : File , all : Seq [File ], appConfiguration : AppConfiguration
544+ state : State , dottyVersion : String , scalaLibrary : File , dottyLibrary : File , compiler : File , all : Seq [File ]
550545 ): ScalaInstance = {
551546 /**
552547 * The compiler bridge must load the xsbti classes from the sbt
553548 * classloader, and similarly the Scala repl must load the sbt provided
554- * jline terminal. To do so we add the `appConfiguration` loader in
555- * the parent hierarchy of the scala 3 instance loader.
556- *
557- * The [[FilteringClassLoader ]] ensures that the JNA, JDK and xsbti
558- * classes only are loaded from the sbt loader. That is necessary because
559- * the sbt class loader contains the Scala 2.12 library and compiler
560- * bridge.
549+ * jline terminal.
561550 */
562- val topLoader = new FilteringClassLoader (appConfiguration.provider.loader)
551+ val topLoader = new ClassLoader (null ) {
552+ val sharedPrefixes = List (
553+ " xsbti." ,
554+ " org.jline."
555+ )
556+
557+ override def loadClass (name : String ): Class [_] = {
558+ if (sharedPrefixes.exists(name.startsWith(_))) getClass.getClassLoader.loadClass(name)
559+ else super .loadClass(name)
560+ }
561+ }
563562
564563 val libraryJars = Array (dottyLibrary, scalaLibrary)
565564 val libraryLoader = state.classLoaderCache.cachedCustomClassloader(
@@ -583,27 +582,3 @@ object DottyPlugin extends AutoPlugin {
583582 None )
584583 }
585584}
586-
587- private class FilteringClassLoader (parent : ClassLoader ) extends ClassLoader (parent) {
588- private val prefixes = List (
589- " xsbti." ,
590- " org.jline." ,
591- " java." ,
592- " sun." ,
593- " jdk.internal.reflect." ,
594- " javax."
595- )
596-
597- override def loadClass (name : String , resolve : Boolean ): Class [_] = {
598- if (prefixes.exists(name.startsWith(_))) super .loadClass(name, resolve)
599- else null
600- }
601-
602- override def getResource (name : String ): URL = {
603- null
604- }
605-
606- override def getResources (name : String ): Enumeration [URL ] = {
607- Collections .enumeration(Collections .emptyList());
608- }
609- }
0 commit comments