@@ -8,13 +8,9 @@ import sbt.librarymanagement.{
8
8
VersionNumber
9
9
}
10
10
import sbt .internal .inc .ScalaInstance
11
- import sbt .internal .inc .classpath .ClassLoaderCache
12
11
import xsbti .compile ._
13
- import xsbti .AppConfiguration
14
12
import java .net .URLClassLoader
15
13
import java .util .Optional
16
- import java .util .{Enumeration , Collections }
17
- import java .net .URL
18
14
import scala .util .Properties .isJavaAtLeast
19
15
20
16
@@ -539,27 +535,30 @@ object DottyPlugin extends AutoPlugin {
539
535
scalaLibraryJar,
540
536
dottyLibraryJar,
541
537
compilerJar,
542
- allJars,
543
- appConfiguration.value
538
+ allJars
544
539
)
545
540
}
546
541
547
542
// Adapted from private mkScalaInstance in sbt
548
543
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 ]
550
545
): ScalaInstance = {
551
546
/**
552
547
* The compiler bridge must load the xsbti classes from the sbt
553
548
* 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.
561
550
*/
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
+ }
563
562
564
563
val libraryJars = Array (dottyLibrary, scalaLibrary)
565
564
val libraryLoader = state.classLoaderCache.cachedCustomClassloader(
@@ -583,27 +582,3 @@ object DottyPlugin extends AutoPlugin {
583
582
None )
584
583
}
585
584
}
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