-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Preliminary support for Java 9 #5385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
First parts of the big TODO list at scala/scala-dev#139 |
/rebuild |
b718eab
to
2db7e8d
Compare
|
/rebuild |
2db7e8d
to
35fa3b2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, not sure about the MiMa failure..
override def output = Files.newOutputStream(nioPath) | ||
override def sizeOption = Some(Files.size(nioPath).toInt) | ||
|
||
override def toString = path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you mean fpath
?
/** Delete the underlying file or directory (recursively). */ | ||
def delete(): Unit = | ||
if (Files.isRegularFile(nioPath)) Files.deleteIfExists(nioPath) | ||
else if (Files.isDirectory(nioPath)) ??? // TODO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably not relevant, but for now you could do new Directory(file).deleteRecursively()
protected def toAbstractFile(f: Path): AbstractFile = new scala.reflect.io.PlainNioFile(f) | ||
protected def isPackage(f: Path): Boolean = Files.isDirectory(f) && mayBeValidPackage(f.getFileName.toString) | ||
|
||
assert(dir != null, "Directory file in DirectoryFileLookup cannot be null") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe move this up to the field definition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed it altogether, it can't trip in this class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's still there..
def name = nioPath.getFileName.toString | ||
|
||
/** Returns the path of this abstract file. */ | ||
def path = nioPath.getParent.toString |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getParent
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops. Fixed that, and I've also stress tested this by using it by default for a commit (then chickening out and reverting it in the following commit)
bc40deb
to
7fb1e92
Compare
I've marked |
7fb1e92
to
53d2e7a
Compare
LGTM, maybe squash the last 4 |
def apply(): List[ClassPath] = { | ||
try { | ||
val fs = FileSystems.getFileSystem(URI.create("jrt:/")) | ||
val dir: Path = fs.getPath("/modules") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw, where's the spec for jrt:/modules/...
? in http://openjdk.java.net/jeps/220 i could only find
A jrt URL is a hierarchical URI, per RFC 3986, with the syntax
jrt:/[$MODULE[/$PATH]]
and
jrt:/
refers to the entire collection of class and resource files stored in the current run-time image.
example: jrt:/java.base/java/lang/Class.class
OK, Google. https://bugs.openjdk.java.net/browse/JDK-8066492
protected def toAbstractFile(f: Path): AbstractFile = new scala.reflect.io.PlainNioFile(f) | ||
protected def isPackage(f: Path): Boolean = Files.isDirectory(f) && mayBeValidPackage(f.getFileName.toString) | ||
|
||
assert(dir != null, "Directory file in DirectoryFileLookup cannot be null") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's still there..
Needs a rebase (and some squashing?) |
53d2e7a
to
37650ec
Compare
This was not having the desired effect of placing the Scala library on the JVM's regular classpath. This commit honours this setting. Note that the Windows scripts have never supported the use of bootclasspath, so no changes are required. The existing bug: ``` (java_use 1.8; ~/scala/2.11.8/bin/scala -nobootcp -debug -e 'print("")') /Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home/bin/java -Xmx256M -Xms32M -Xbootclasspath/a:/Users/jason/scala/2.11.8/lib/akka-actor_2.11-2.3.10.jar:/Users/jason/scala/2.11.8/lib/config-1.2.1.jar:/Users/jason/scala/2.11.8/lib/jline-2.12.1.jar:/Users/jason/scala/2.11.8/lib/scala-actors-2.11.0.jar:/Users/jason/scala/2.11.8/lib/scala-actors-migration_2.11-1.1.0.jar:/Users/jason/scala/2.11.8/lib/scala-compiler.jar:/Users/jason/scala/2.11.8/lib/scala-continuations-library_2.11-1.0.2.jar:/Users/jason/scala/2.11.8/lib/scala-continuations-plugin_2.11.8-1.0.2.jar:/Users/jason/scala/2.11.8/lib/scala-library.jar:/Users/jason/scala/2.11.8/lib/scala-parser-combinators_2.11-1.0.4.jar:/Users/jason/scala/2.11.8/lib/scala-reflect.jar:/Users/jason/scala/2.11.8/lib/scala-swing_2.11-1.0.2.jar:/Users/jason/scala/2.11.8/lib/scala-xml_2.11-1.0.4.jar:/Users/jason/scala/2.11.8/lib/scalap-2.11.8.jar -classpath "" -Dscala.home=/Users/jason/scala/2.11.8 -Dscala.usejavacp=true -Denv.emacs= scala.tools.nsc.MainGenericRunner print("") ``` Fixed by this patch: ``` ⚡ (java_use 1.8; qscala -nobootcp -debug -e 'print("")') /Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home/bin/java -Xmx256M -Xms32M -classpath /Users/jason/code/scala/build/quick/classes/repl-jline-embedded:/Users/jason/code/scala/build/quick/classes/repl-jline:/Users/jason/code/scala/build/quick/classes/repl:/Users/jason/code/scala/build/quick/classes/compiler:/Users/jason/code/scala/build/quick/classes/library:/Users/jason/code/scala/build/quick/classes/reflect:/Users/jason/code/scala/build/quick/classes/interactive:/Users/jason/.ivy2/cache/org.apache.ant/ant/jars/ant-1.9.4.jar:/Users/jason/.ivy2/cache/org.apache.ant/ant-launcher/jars/ant-launcher-1.9.4.jar:/Users/jason/.ivy2/cache/org.scala-lang.modules/scala-asm/bundles/scala-asm-5.1.0-scala-1.jar:/Users/jason/.ivy2/cache/org.scala-lang.modules/scala-xml_2.12.0-RC1/bundles/scala-xml_2.12.0-RC1-1.0.5.jar:/Users/jason/.ivy2/cache/jline/jline/jars/jline-2.14.1.jar -Dscala.home=/Users/jason/code/scala/build/quick -Dscala.usejavacp=true -Denv.emacs= scala.tools.nsc.MainGenericRunner -nc print("") ```
In Java 9. we can no longer introspect the boot classpath with a JVM provided system property. Instead, this commit passes a custom property which will be found by PathResolver when it constructs the compiler classpath.
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 b2d0a17a which passed CI. But to be conservative, I'm not submitting that change at this point.
37650ec
to
159480f
Compare
All done. |
Should we release-note this? Or is it not enough Java 9 support to yet be worth highlighting? |
I'm fine either way. Not sure how much testing Jason did on JDK 9, the only thing I did was |
Includes a fix for SI-9833