summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/classpath/ClassPathFactory.scala
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2016-04-24 17:23:20 +1000
committerJason Zaugg <jzaugg@gmail.com>2016-12-02 11:30:47 +1000
commit159480f2504cc08f9cc35660cc33090a49e0228e (patch)
tree741982f0327fd013d6f218b5582adea5d7d93fd4 /src/compiler/scala/tools/nsc/classpath/ClassPathFactory.scala
parentbfa7ade0db6d36efc721e36dc41627dbd76b0176 (diff)
downloadscala-159480f2504cc08f9cc35660cc33090a49e0228e.tar.gz
scala-159480f2504cc08f9cc35660cc33090a49e0228e.tar.bz2
scala-159480f2504cc08f9cc35660cc33090a49e0228e.zip
Support Java 9 modular runtime images
http://openjdk.java.net/jeps/220 changes the layout of the JDK to encapsulate the provided libraries with the new module system. This commit modifies the compiler's classpath implementation to scan the new location of these, the `jrt://` virtual filesystem. This might need to be adjusted once we provide a means for users to specify the subset of modules that they want to depend on, but for now reclaims the ground we lost. ``` ⚡ (java_use 9-ea; qscala) Welcome to Scala 2.12.0-20160908-223617-7e4ebda (Java HotSpot(TM) 64-Bit Server VM, Java 9-ea). Type in expressions for evaluation. Or try :help. scala> import StackWalker._, java.util.stream._, scala.collection.JavaConverters._ import StackWalker._ import java.util.stream._ import scala.collection.JavaConverters._ scala> (() => StackWalker.getInstance(java.util.EnumSet.of(Option.RETAIN_CLASS_REFERENCE)).walk[Seq[String]]((s: java.util.stream.Stream[StackFrame]) => s.iterator.asScala.take(3).map(_.toString).toList)).apply().mkString("\n") res0: String = .$anonfun$res0$1(<console>:21) .<init>(<console>:21) .<clinit>(<console>) scala> ``` I've marked the new class, `NioFile` as `private[scala]` to justify the forward compatibility whitelist entry. In principle we could use NioFile more widely rather than `PlainFile` I tried this out in https://github.com/retronym/scala/commit/b2d0a17a which passed CI. But to be conservative, I'm not submitting that change at this point.
Diffstat (limited to 'src/compiler/scala/tools/nsc/classpath/ClassPathFactory.scala')
-rw-r--r--src/compiler/scala/tools/nsc/classpath/ClassPathFactory.scala6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/classpath/ClassPathFactory.scala b/src/compiler/scala/tools/nsc/classpath/ClassPathFactory.scala
index 3a29f1ba11..80c5ec8828 100644
--- a/src/compiler/scala/tools/nsc/classpath/ClassPathFactory.scala
+++ b/src/compiler/scala/tools/nsc/classpath/ClassPathFactory.scala
@@ -4,6 +4,7 @@
package scala.tools.nsc.classpath
import scala.reflect.io.{AbstractFile, VirtualDirectory}
+import scala.reflect.io.Path.string2path
import scala.tools.nsc.Settings
import FileUtils.AbstractFileOps
import scala.tools.nsc.util.ClassPath
@@ -52,7 +53,10 @@ class ClassPathFactory(settings: Settings) {
protected def classesInPathImpl(path: String, expand: Boolean) =
for {
file <- expandPath(path, expand)
- dir <- Option(AbstractFile.getDirectory(file))
+ dir <- {
+ def asImage = if (file.endsWith(".jimage")) Some(AbstractFile.getFile(file)) else None
+ Option(AbstractFile.getDirectory(file)).orElse(asImage)
+ }
} yield newClassPath(dir)
private def createSourcePath(file: AbstractFile): ClassPath =