Skip to content

Commit

Permalink
Layered class loading of library and compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
retronym authored and eed3si9n committed Mar 2, 2018
1 parent a17567c commit 2b07b4b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 9 additions & 2 deletions launcher-implementation/src/main/scala/xsbt/boot/Launch.scala
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,18 @@ class Launch private[xsbt] (val bootDirectory: File, val lockBoot: Boolean, val
}
def componentProvider(appHome: File) = new ComponentProvider(appHome, lockBoot)

def scalaProvider(scalaVersion: String, module: RetrievedModule, parentLoader: ClassLoader, scalaLibDir: File): xsbti.ScalaProvider = new xsbti.ScalaProvider {
def scalaProvider(scalaVersion: String, module: RetrievedModule, parentLoader: ClassLoader, scalaLibDir: File): xsbti.ScalaProvider = new xsbti.ExtendedScalaProvider {
def launcher = Launch.this
def version = scalaVersion
lazy val loader = module.createLoader(parentLoader)

private object LoaderInit {
val (library, other) = module.fullClasspath.partition(_.getName.startsWith("scala-library"))
val libraryLoader = new URLClassLoader(toURLs(library), parentLoader)
val fullLoader = new URLClassLoader(toURLs(other), libraryLoader)
}

override def loaderLibraryOnly(): ClassLoader = LoaderInit.libraryLoader
override def loader(): ClassLoader = LoaderInit.fullLoader
def compilerJar = new File(scalaLibDir, CompilerModuleName + ".jar")
def libraryJar = new File(scalaLibDir, LibraryModuleName + ".jar")
def jars = module.fullClasspath
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package xsbti;

public interface ExtendedScalaProvider extends ScalaProvider
{
/** A ClassLoader that loads the classes from scala-library.jar. It will be the parent of `loader` .*/
public ClassLoader loaderLibraryOnly();
}

0 comments on commit 2b07b4b

Please sign in to comment.