Merge pull request #3701 from retronym/ticket/bootclasspath

Fix over-compilation bug with Java 9, scala.ext.dir
This commit is contained in:
eugene yokota 2017-11-05 22:33:45 -05:00 committed by GitHub
commit a5bd564307
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 3 deletions

View File

@ -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 _ => ()
}

View File

@ -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"