diff --git a/compile/interface/src/main/scala/xsbt/Dependency.scala b/compile/interface/src/main/scala/xsbt/Dependency.scala index 34c237bb3..c20974790 100644 --- a/compile/interface/src/main/scala/xsbt/Dependency.scala +++ b/compile/interface/src/main/scala/xsbt/Dependency.scala @@ -63,7 +63,13 @@ final class Dependency(val global: CallbackGlobal) extends LocateClassFile with case Some((f, className, inOutDir)) => if (inOutDir && on.isJavaDefined) registerTopLevelSym(on) f match { - case ze: ZipArchive#Entry => for (zip <- ze.underlyingSource; zipFile <- Option(zip.file)) binaryDependency(zipFile, className) + case ze: ZipArchive#Entry => + // Scala 2.10/2.11 give back $JAVA_HOME as the underlying source for the platform classloader + // See https://github.com/scala/scala/pull/6113. Treating that as not having an underlying source + // is the least bad option for now. We would not trigger a recompile if the JDK is updated, but that + // is better than recompiling *every* time, which seems to happen if we let the directory propagate + // to `binaryDependency`. + for (zip <- ze.underlyingSource; zipFile <- Option(zip.file).filterNot(_.isDirectory)) binaryDependency(zipFile, className) case pf: PlainFile => binaryDependency(pf.file, className) case _ => () } diff --git a/compile/src/main/scala/sbt/compiler/CompilerArguments.scala b/compile/src/main/scala/sbt/compiler/CompilerArguments.scala index df279bb37..6a2a41056 100644 --- a/compile/src/main/scala/sbt/compiler/CompilerArguments.scala +++ b/compile/src/main/scala/sbt/compiler/CompilerArguments.scala @@ -45,7 +45,14 @@ final class CompilerArguments(scalaInstance: xsbti.compile.ScalaInstance, cp: xs /** Add the correct Scala library jar to the boot classpath if `addLibrary` is true.*/ def createBootClasspath(addLibrary: Boolean) = { - val originalBoot = System.getProperty("sun.boot.class.path", "") + def findBoot: String = + { + import scala.collection.JavaConverters._ + System.getProperties.asScala.iterator.collectFirst { + case (k, v) if k.endsWith(".boot.class.path") => v + }.getOrElse("") + } + val originalBoot = Option(System.getProperty("sun.boot.class.path")).getOrElse(findBoot) if (addLibrary) { val newBootPrefix = if (originalBoot.isEmpty) "" else originalBoot + File.pathSeparator newBootPrefix + scalaInstance.libraryJar.getAbsolutePath @@ -63,7 +70,7 @@ final class CompilerArguments(scalaInstance: xsbti.compile.ScalaInstance, cp: xs def bootClasspathFor(classpath: Seq[File]) = bootClasspath(hasLibrary(classpath)) import Path._ - def extClasspath: Seq[File] = (IO.parseClasspath(System.getProperty("java.ext.dirs", "")) * "*.jar").get + def extClasspath: Seq[File] = List("java.ext.dirs", "scala.ext.dirs").flatMap(k => (IO.parseClasspath(System.getProperty(k, "")) * "*.jar").get) } object CompilerArguments { val BootClasspathOption = "-bootclasspath"