-
Notifications
You must be signed in to change notification settings - Fork 3.1k
[backport] Adapt to changes in Java 9 #6113
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
We used to rely on `cls.getPackage == null` for `cls` defined in the empty package. Under Java 9, we actually get the empty package back from that call. This commit ensures we use the one true empty package symbol on either Java 8 or 9. (cherry picked from commit b81bc77)
2cf4a6a
to
e43d48c
Compare
If there's going to be a 2.10.7 version for the sake of Java 9 support, could 72076e5 also be ported please? It is necessary for parallel collections not to crash on Java 9. This caused issues in Scala.js, which forced us to plain disable parallelism in the Scala.js optimizer on Java 9. |
👍 on what Sébastien said, #5276 was also mentioned in playframework/playframework#7879. [edit: Oh, it has been cherry picked into this PR] |
Thanks! 🙇♂️ |
Oh version numbers!
|
I don't mean to throw more weight on the backport wagon, but I hit this exact thing yesterday when doing some JDK 9 related work in a 2.11 cross-built codebase. And had to resort to some variant of isJavaAtLeast. (sbt/librarymanagement#173). So backporting that fix too would be ace.. |
The utility method compares javaSpecVersion, which has the form "1.8" previously and "9" going forward. The method accepts "1.n" for n < 9. More correctly, the string argument should be a single number. Supports JEP-223. (cherry picked from commit 72076e5) Also cherry-picks subsequent bug fixes and test improvements from 06f8b62 Backport accumulated improvements, tests for isJavaAtLeast
3817b40
to
05cdf51
Compare
I've backported the accumulated fixes and tests for |
trying another Jenkins validate-main run with the new commits: https://scala-ci.typesafe.com/view/scala-2.11.x/job/scala-2.11.x-validate-main/3157/consoleFull (as Adriaan realized, although Scabot ignores the 2.10.x branch, you can manually trigger a 2.10.x run of validate-main using the 2.11.x job) |
publish-core succeeded ( but,
|
which asm version was in there before? i could not easily find out looking at the git history. |
46ba07e
to
91db09e
Compare
In Scala 2.13.x, we've supported this by using the NIO jrt:// virtual filesystem. We can't (easily) ship code in older Scala distributions that require Java 7+, but we can fall back to use of `javax.tools`, which offers programatic access to the Java compiler's classpath implementation. This is incompatible with the performance trick used in the runner scripts that places the Scala compiler on the JVM boot classpath to avoid the cost of classfile verification. The boot classpath can only see the base platform on Java 9, which puts `javax.tools` out of access. But, we can use `scalac -nobootcp` to make things work! This obviates the workaround used in SBT which exports rt.jar from JDK9 and passes to scalac as a custom boot classpath.
91db09e
to
2f6be1b
Compare
Disk space problem on jenkins-worker-behemoth-2?
|
|
6bf893e
to
ded1024
Compare
The Scala classfile and java source parsers make Java annotation classes (which are actually interfaces at the classfile level) look like Scala annotation classes: - the INTERFACE / ABSTRACT flags are not added - scala.annotation.Annotation is added as superclass - scala.annotation.ClassfileAnnotation is added as interface This makes type-checking @annot uniform, whether it is defined in Java or Scala. This is a hack that leads to various bugs (SI-9393, SI-9400). Instead the type-checking should be special-cased for Java annotations. This commit fixes SI-9393 and a part of SI-9400, but it's still easy to generate invalid classfiles. Restores the assertions that were disabled in scala#4621. I'd like to leave these assertions in: they are valuable and helped uncovering the issue being fixed here. A new flag JAVA_ANNOTATION is introduced for Java annotation ClassSymbols, similar to the existing ENUM flag. When building ClassBTypes for Java annotations, the flags, superclass and interfaces are recovered to represent the situation in the classfile. The test for SI-9393 is extended to test both the classfile and the java source parser. Partial cherry pick of 77b8b6a
Without this, you get: ``` (java_use 9; qscalac -nobootcp $(f "class C { java.util.List.of(this, this)}" ) && qscala -nobootcp -e 'new C') java.lang.VerifyError: Illegal type at constant pool entry 18 in class C Exception Details: Location: C.<init>()V @6: invokestatic Reason: Constant pool index 18 is invalid Bytecode: 0000000: 2ab7 000c 2a2a b800 1257 b1 ``` See https://bugs.openjdk.java.net/browse/JDK-8037385
ded1024
to
7e1a4b9
Compare
😕 |
Restored that file, I'm guessing it was accidentally deleted in a manual purge of |
LGTM, a bit of squashing. ASM update looks good too, I went through asm changes in 2.12.x. Curious, why did you backport the fix for scala/bug#9393? |
Actually, why did you move the asm sources from |
I adapted GenASM to set the
Nope, that was a mistake. I'll move them back. I'll also do a jardiff after a bootstrap to doublecheck things are okay. |
Only one diff, but one that I can't immediately explain. diff --git a/scala/collection/parallel/ParIterableLike.class.asm b/scala/collection/parallel/ParIterableLike.class.asm
index e7ebdef..0c753e0 100644
--- a/scala/collection/parallel/ParIterableLike.class.asm
+++ b/scala/collection/parallel/ParIterableLike.class.asm
@@ -157,9 +157,9 @@
// access flags 0x1
public INNERCLASS scala/collection/parallel/ParIterableLike$CreateScanTree scala/collection/parallel/ParIterableLike CreateScanTree
// access flags 0x401
- public abstract INNERCLASS scala/collection/parallel/ParIterableLike$Accessor$class scala/collection/parallel/ParIterableLike Accessor$class
- // access flags 0x401
public abstract INNERCLASS scala/collection/parallel/ParIterableLike$ScanTree$class scala/collection/parallel/ParIterableLike ScanTree$class
+ // access flags 0x401
+ public abstract INNERCLASS scala/collection/parallel/ParIterableLike$Accessor$class scala/collection/parallel/ParIterableLike Accessor$class
// access flags 0x1
public INNERCLASS scala/collection/parallel/ParIterableLike$$anonfun$min$1 null null
// access flags 0x1
diff --git a/scala/tools/nsc/symtab/SymbolTrackers$SymbolTracker$Node$.class.asm b/scala/tools/nsc/symtab/SymbolTrackers$SymbolTracker$Node$.class.asm
index 878393a..7d6f2af 100644
--- a/scala/tools/nsc/symtab/SymbolTrackers$SymbolTracker$Node$.class.asm
+++ b/scala/tools/nsc/symtab/SymbolTrackers$SymbolTracker$Node$.class.asm
@@ -187,9 +187,7 @@
INVOKEVIRTUAL scala/collection/immutable/Set$.canBuildFrom ()Lscala/collection/generic/CanBuildFrom;
INVOKEINTERFACE scala/collection/SetLike.map (Lscala/Function1;Lscala/collection/generic/CanBuildFrom;)Ljava/lang/Object;
CHECKCAST scala/collection/GenTraversableOnce
- GETSTATIC scala/collection/immutable/Set$.MODULE$ : Lscala/collection/immutable/Set$;
- INVOKEVIRTUAL scala/collection/immutable/Set$.canBuildFrom ()Lscala/collection/generic/CanBuildFrom;
- INVOKEINTERFACE scala/collection/immutable/Set.$plus$plus (Lscala/collection/GenTraversableOnce;Lscala/collection/generic/CanBuildFrom;)Ljava/lang/Object;
+ INVOKEINTERFACE scala/collection/immutable/Set.$plus$plus (Lscala/collection/GenTraversableOnce;)Lscala/collection/Set;
CHECKCAST scala/collection/immutable/Set
ALOAD 0
GETFIELD scala/tools/nsc/symtab/SymbolTrackers$SymbolTracker$Node$.$outer : Lscala/tools/nsc/symtab/SymbolTrackers$SymbolTracker; Produced with:
|
Okay, I see now that I was in fact testing differences in using 2.10.3 (starr.version) and the tip of this PR in code generation. Something seems to have changed overload resolution between 2.10.3 and 2.10.4, which is unrelated to this PR. |
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.
just a bit of squashing left to do, looks all good otherwise.
I left this unsquashed for now to make it a bit easier to create the forward merge to 2.11.x, #6151. I've got that PR green now, so I could rebase/squash this and turn the 2.11.x version into a single commit. |
+1 I think it's fine to leave the history in place for expediency as well as future archeology |
FTR, I've had a report of this exception when using Java 9, SBT 0.13.17, which uses the new code here to compile
I believe this is due to using a JRE rather than JDK, which gives a null from val fileManager = ToolProvider.getSystemJavaCompiler.getStandardFileManager(new DiagnosticCollector, java.util.Locale.getDefault, Charset.defaultCharset) |
Backports of a few changes in Scala 2.12.3 that remove some impediments to running on Java 9.