Skip to content

Instantly share code, notes, and snippets.

@smparkes
Created April 27, 2011 18:15
Show Gist options
  • Save smparkes/944826 to your computer and use it in GitHub Desktop.
Save smparkes/944826 to your computer and use it in GitHub Desktop.
diff --git a/compile/ScalaInstance.scala b/compile/ScalaInstance.scala
index 9f13b1b..4c7da29 100644
--- a/compile/ScalaInstance.scala
+++ b/compile/ScalaInstance.scala
@@ -7,8 +7,12 @@ package xsbt
* for the compiler itself.
* The 'version' field is the version used to obtain the Scala classes. This is typically the version for the maven repository.
* The 'actualVersion' field should be used to uniquely identify the compiler. It is obtained from the compiler.properties file.*/
-final class ScalaInstance(val version: String, val loader: ClassLoader, val libraryJar: File, val compilerJar: File, val extraJars: Seq[File]) extends NotNull
+final class ScalaInstance(val version: String, val parentLoader: ClassLoader, val libraryJar: File, val compilerJar: File, val extraJars: Seq[File]) extends NotNull
{
+ var jniLoader: ClassLoader = null;
+
+ def loader: ClassLoader = if (jniLoader != null) jniLoader else parentLoader
+
require(version.indexOf(' ') < 0, "Version cannot contain spaces (was '" + version + "')")
def jars = libraryJar :: compilerJar :: extraJars.toList
/** Gets the version of Scala in the compiler.properties file from the loader. This version may be different than that given by 'version'*/
@@ -54,4 +58,4 @@ object ScalaInstance
private def scalaLoader(launcher: xsbti.Launcher, jars: Seq[File]): ClassLoader =
new URLClassLoader(jars.map(_.toURI.toURL).toArray[URL], launcher.topLoader)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment