From d9df8835e67470849aa5efa8ed9330b421143427 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Sun, 5 Nov 2017 13:54:29 +1100 Subject: [PATCH] Add comment about reason for underlying source hack --- compile/interface/src/main/scala/xsbt/Dependency.scala | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/compile/interface/src/main/scala/xsbt/Dependency.scala b/compile/interface/src/main/scala/xsbt/Dependency.scala index 9f203308f..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).filterNot(_.isDirectory)) 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 _ => () }