@@ -539,27 +539,30 @@ object DottyPlugin extends AutoPlugin {
539
539
scalaLibraryJar,
540
540
dottyLibraryJar,
541
541
compilerJar,
542
- allJars,
543
- appConfiguration.value
542
+ allJars
544
543
)
545
544
}
546
545
547
546
// Adapted from private mkScalaInstance in sbt
548
547
def makeScalaInstance (
549
- state : State , dottyVersion : String , scalaLibrary : File , dottyLibrary : File , compiler : File , all : Seq [File ], appConfiguration : AppConfiguration
548
+ state : State , dottyVersion : String , scalaLibrary : File , dottyLibrary : File , compiler : File , all : Seq [File ]
550
549
): ScalaInstance = {
551
550
/**
552
551
* The compiler bridge must load the xsbti classes from the sbt
553
552
* 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.
553
+ * jline terminal.
561
554
*/
562
- val topLoader = new FilteringClassLoader (appConfiguration.provider.loader)
555
+ val topLoader = new ClassLoader (null ) {
556
+ val sharedPrefixes = List (
557
+ " xsbti." ,
558
+ " org.jline."
559
+ )
560
+
561
+ override def loadClass (name : String ): Class [_] = {
562
+ if (sharedPrefixes.exists(name.startsWith(_))) getClass.getClassLoader.loadClass(name)
563
+ else super .loadClass(name)
564
+ }
565
+ }
563
566
564
567
val libraryJars = Array (dottyLibrary, scalaLibrary)
565
568
val libraryLoader = state.classLoaderCache.cachedCustomClassloader(
@@ -583,27 +586,3 @@ object DottyPlugin extends AutoPlugin {
583
586
None )
584
587
}
585
588
}
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