class ScalaInstanceTopLoader extends ClassLoader
The parent classloader of the Scala compiler. It was originally copied and pasted from https://github.com/lampepfl/dotty/blob/ea65338e06142f41f0e68b23250c8e22b0ba8837/sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala#L586-L627
To understand why a custom parent classloader is needed for the compiler, let us describe some alternatives that wouldn't work.
- new URLClassLoader(urls)
:
The compiler contains sbt phases that callback to sbt using the xsbti.*
interfaces. If urls
does not contain the sbt interfaces we'll get a
ClassNotFoundException
in the compiler when we try to use them, if
urls
does contain the interfaces we'll get a ClassCastException
or a
LinkageError
because if the same class is loaded by two different
classloaders, they are considered distinct by the JVM.
- new URLClassLoader(urls, bloopLoader)
:
Because of the JVM delegation model, this means that we will only load
a class from urls
if it's not present in the parent bloopLoader
, but
Bloop uses its own version of the scala library which is not the one we
need to run the compiler.
Our solution is to implement an URLClassLoader whose parent is
new ScalaInstanceTopLoader(bloopClassLoader, bootClassLoader)
.
We override loadClass
to load the xsbti.*
interfaces from the
bloopClassLoader
and the JDK classes from the bootClassLoader.
- Alphabetic
- By Inheritance
- ScalaInstanceTopLoader
- ClassLoader
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new ScalaInstanceTopLoader(bloopClassLoader: ClassLoader, parent: ClassLoader)
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clearAssertionStatus(): Unit
- Definition Classes
- ClassLoader
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native() @IntrinsicCandidate()
-
final
def
defineClass(arg0: String, arg1: ByteBuffer, arg2: ProtectionDomain): Class[_]
- Attributes
- protected[lang]
- Definition Classes
- ClassLoader
- Annotations
- @throws( classOf[java.lang.ClassFormatError] )
-
final
def
defineClass(arg0: String, arg1: Array[Byte], arg2: Int, arg3: Int, arg4: ProtectionDomain): Class[_]
- Attributes
- protected[lang]
- Definition Classes
- ClassLoader
- Annotations
- @throws( classOf[java.lang.ClassFormatError] )
-
final
def
defineClass(arg0: String, arg1: Array[Byte], arg2: Int, arg3: Int): Class[_]
- Attributes
- protected[lang]
- Definition Classes
- ClassLoader
- Annotations
- @throws( classOf[java.lang.ClassFormatError] )
-
def
definePackage(arg0: String, arg1: String, arg2: String, arg3: String, arg4: String, arg5: String, arg6: String, arg7: URL): Package
- Attributes
- protected[lang]
- Definition Classes
- ClassLoader
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
findClass(arg0: String, arg1: String): Class[_]
- Attributes
- protected[lang]
- Definition Classes
- ClassLoader
-
def
findClass(arg0: String): Class[_]
- Attributes
- protected[lang]
- Definition Classes
- ClassLoader
- Annotations
- @throws( ... )
-
def
findLibrary(arg0: String): String
- Attributes
- protected[lang]
- Definition Classes
- ClassLoader
-
final
def
findLoadedClass(arg0: String): Class[_]
- Attributes
- protected[lang]
- Definition Classes
- ClassLoader
-
def
findResource(arg0: String): URL
- Attributes
- protected[lang]
- Definition Classes
- ClassLoader
-
def
findResource(arg0: String, arg1: String): URL
- Attributes
- protected[lang]
- Definition Classes
- ClassLoader
- Annotations
- @throws( classOf[java.io.IOException] )
-
def
findResources(arg0: String): Enumeration[URL]
- Attributes
- protected[lang]
- Definition Classes
- ClassLoader
- Annotations
- @throws( classOf[java.io.IOException] )
-
final
def
findSystemClass(arg0: String): Class[_]
- Attributes
- protected[lang]
- Definition Classes
- ClassLoader
- Annotations
- @throws( ... )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @IntrinsicCandidate()
-
def
getClassLoadingLock(arg0: String): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- ClassLoader
-
final
def
getDefinedPackage(arg0: String): Package
- Definition Classes
- ClassLoader
-
final
def
getDefinedPackages(): Array[Package]
- Definition Classes
- ClassLoader
-
def
getName(): String
- Definition Classes
- ClassLoader
-
def
getPackages(): Array[Package]
- Attributes
- protected[lang]
- Definition Classes
- ClassLoader
-
final
def
getParent(): ClassLoader
- Definition Classes
- ClassLoader
- Annotations
- @CallerSensitive()
-
def
getResource(arg0: String): URL
- Definition Classes
- ClassLoader
-
def
getResourceAsStream(arg0: String): InputStream
- Definition Classes
- ClassLoader
-
def
getResources(arg0: String): Enumeration[URL]
- Definition Classes
- ClassLoader
- Annotations
- @throws( classOf[java.io.IOException] )
-
final
def
getUnnamedModule(): Module
- Definition Classes
- ClassLoader
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @IntrinsicCandidate()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
isRegisteredAsParallelCapable(): Boolean
- Definition Classes
- ClassLoader
-
def
loadClass(name: String, resolve: Boolean): Class[_]
- Attributes
- protected
- Definition Classes
- ScalaInstanceTopLoader → ClassLoader
-
def
loadClass(arg0: String): Class[_]
- Definition Classes
- ClassLoader
- Annotations
- @throws( ... )
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
-
final
def
resolveClass(arg0: Class[_]): Unit
- Attributes
- protected[lang]
- Definition Classes
- ClassLoader
-
def
resources(arg0: String): Stream[URL]
- Definition Classes
- ClassLoader
-
def
setClassAssertionStatus(arg0: String, arg1: Boolean): Unit
- Definition Classes
- ClassLoader
-
def
setDefaultAssertionStatus(arg0: Boolean): Unit
- Definition Classes
- ClassLoader
-
def
setPackageAssertionStatus(arg0: String, arg1: Boolean): Unit
- Definition Classes
- ClassLoader
-
final
def
setSigners(arg0: Class[_], arg1: Array[AnyRef]): Unit
- Attributes
- protected[lang]
- Definition Classes
- ClassLoader
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
Deprecated Value Members
-
final
def
defineClass(arg0: Array[Byte], arg1: Int, arg2: Int): Class[_]
- Attributes
- protected[lang]
- Definition Classes
- ClassLoader
- Annotations
- @throws( classOf[java.lang.ClassFormatError] ) @Deprecated
- Deprecated
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] ) @Deprecated
- Deprecated
-
def
getPackage(arg0: String): Package
- Attributes
- protected[lang]
- Definition Classes
- ClassLoader
- Annotations
- @Deprecated
- Deprecated