Skip to content

compiler does not work with "-opt:l:method" on JDK10 #10717

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

Closed
xuwei-k opened this issue Feb 12, 2018 · 20 comments
Closed

compiler does not work with "-opt:l:method" on JDK10 #10717

xuwei-k opened this issue Feb 12, 2018 · 20 comments

Comments

@xuwei-k
Copy link

xuwei-k commented Feb 12, 2018

package example

class Foo
$ scala -version
Scala code runner version 2.13.0-M3 -- Copyright 2002-2018, LAMP/EPFL and Lightbend, Inc.
$ java -version
java version "10-ea" 2018-03-20
Java(TM) SE Runtime Environment 18.3 (build 10-ea+42)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10-ea+42, mixed mode)
$ scalac -opt:l:method Foo.scala
error: java.lang.IllegalArgumentException
	at scala.tools.asm.ClassReader.<init>(ClassReader.java:160)
	at scala.tools.asm.ClassReader.<init>(ClassReader.java:143)
	at scala.tools.nsc.backend.jvm.opt.ByteCodeRepository.$anonfun$parseClass$1(ByteCodeRepository.scala:257)
	at scala.tools.nsc.backend.jvm.opt.ByteCodeRepository.parseClass(ByteCodeRepository.scala:255)
	at scala.tools.nsc.backend.jvm.opt.ByteCodeRepository.$anonfun$parsedClassNode$1(ByteCodeRepository.scala:70)
	at scala.collection.mutable.MapLike.getOrElseUpdate(MapLike.scala:202)
	at scala.collection.mutable.MapLike.getOrElseUpdate$(MapLike.scala:199)
	at scala.collection.mutable.AbstractMap.getOrElseUpdate(Map.scala:80)
	at scala.tools.nsc.backend.jvm.opt.ByteCodeRepository.parsedClassNode(ByteCodeRepository.scala:70)
	at scala.tools.nsc.backend.jvm.opt.ByteCodeRepository.classNode(ByteCodeRepository.scala:91)
	at scala.tools.nsc.backend.jvm.opt.ByteCodeRepository.methodNode(ByteCodeRepository.scala:239)
	at scala.tools.nsc.backend.jvm.opt.CallGraph.$anonfun$addMethod$2(CallGraph.scala:151)
	at scala.tools.nsc.backend.jvm.opt.CallGraph.$anonfun$addMethod$2$adapted(CallGraph.scala:148)
	at scala.collection.Iterator.foreach(Iterator.scala:938)
	at scala.collection.Iterator.foreach$(Iterator.scala:938)
	at scala.collection.AbstractIterator.foreach(Iterator.scala:1426)
	at scala.tools.nsc.backend.jvm.opt.CallGraph.addMethod(CallGraph.scala:148)
	at scala.tools.nsc.backend.jvm.opt.CallGraph.$anonfun$addClass$1(CallGraph.scala:107)
	at scala.tools.nsc.backend.jvm.opt.CallGraph.$anonfun$addClass$1$adapted(CallGraph.scala:107)
	at scala.collection.Iterator.foreach(Iterator.scala:938)
	at scala.collection.Iterator.foreach$(Iterator.scala:938)
	at scala.collection.AbstractIterator.foreach(Iterator.scala:1426)
	at scala.collection.IterableLike.foreach(IterableLike.scala:71)
	at scala.collection.IterableLike.foreach$(IterableLike.scala:70)
	at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
	at scala.tools.nsc.backend.jvm.opt.CallGraph.addClass(CallGraph.scala:107)
	at scala.tools.nsc.backend.jvm.PostProcessor.$anonfun$runGlobalOptimizations$3(PostProcessor.scala:86)
	at scala.tools.nsc.backend.jvm.PostProcessor.$anonfun$runGlobalOptimizations$3$adapted(PostProcessor.scala:84)
	at scala.collection.TraversableLike$WithFilter.$anonfun$foreach$1(TraversableLike.scala:785)
	at scala.collection.immutable.List.foreach(List.scala:389)
	at scala.collection.generic.TraversableForwarder.foreach(TraversableForwarder.scala:35)
	at scala.collection.generic.TraversableForwarder.foreach$(TraversableForwarder.scala:35)
	at scala.collection.mutable.ListBuffer.foreach(ListBuffer.scala:44)
	at scala.collection.TraversableLike$WithFilter.foreach(TraversableLike.scala:784)
	at scala.tools.nsc.backend.jvm.PostProcessor.runGlobalOptimizations(PostProcessor.scala:84)
	at scala.tools.nsc.backend.jvm.PostProcessor.postProcessAndSendToDisk(PostProcessor.scala:46)
	at scala.tools.nsc.backend.jvm.GenBCode$BCodePhase.$anonfun$run$1(GenBCode.scala:54)
	at scala.tools.nsc.backend.jvm.GenBCode$BCodePhase.run(GenBCode.scala:51)
	at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1453)
	at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1437)
	at scala.tools.nsc.Global$Run.compileSources(Global.scala:1429)
	at scala.tools.nsc.Global$Run.compile(Global.scala:1546)
	at scala.tools.nsc.Driver.doCompile(Driver.scala:35)
	at scala.tools.nsc.MainClass.doCompile(Main.scala:24)
	at scala.tools.nsc.Driver.process(Driver.scala:55)
	at scala.tools.nsc.Driver.main(Driver.scala:68)
	at scala.tools.nsc.Main.main(Main.scala)
@SethTisue SethTisue added this to the 2.13.0-RC1 milestone Feb 17, 2018
@lrytz
Copy link
Member

lrytz commented Feb 28, 2018

So this issue should fix itself when we upgrade to asm 6.1 (not yet released), which will include the two commits listed above.

@lrytz lrytz self-assigned this Feb 28, 2018
@lrytz
Copy link
Member

lrytz commented Mar 12, 2018

6.1 is released now https://mail.ow2.org/wws/arc/asm/2018-03/msg00000.html

@ijuma
Copy link

ijuma commented Mar 23, 2018

Is there a plan to upgrade to ASM 6.1 in the Scala 2.12 series?

@lrytz
Copy link
Member

lrytz commented Mar 23, 2018

In general we keep ASM up to date, so I'll probably do it for 2.12. Watching the asm issue tracker, I saw one regression in 6.1 that might be relevant to us: https://gitlab.ow2.org/asm/asm/issues/317815. If we do the update we need to look at this in more detail to see if it affects us. In any case, I'm busy right now with other stuff :)

@ijuma
Copy link

ijuma commented Mar 23, 2018

Thanks for the information.

@mkurz
Copy link

mkurz commented Mar 26, 2018

ASM 6.1.1 has been tagged and also availabe via the maven repos already.
https://gitlab.ow2.org/asm/asm/tags

@Abhi-joshi
Copy link

@lrytz Feasible in 2.12.6?

@Andrei-Pozolotin
Copy link

version "10-ea" 2018-03-20 and 18.3 ? :-)

@adriaanm
Copy link
Contributor

adriaanm commented Apr 4, 2018

We will (carefully) consider an ASM upgrade for 2.12.7, but not 2.12.6.

@adriaanm
Copy link
Contributor

adriaanm commented Apr 4, 2018

It would be a big help if someone could submit our patches in scala/scala-asm upstream to https://gitlab.ow2.org/asm/asm, so that we could switch to using an official asm release. That would simplify upgrading to the latest ASM a lot! (EDIT: the differences are small, but essential for us -- we think they could all go upstream, but just haven't found the time to do so...)

@SethTisue SethTisue modified the milestones: 2.13.0-RC1, 2.12.7 Apr 27, 2018
@SethTisue SethTisue changed the title Scala 2.13.0-M3 compiler does not work with "-opt:l:method" on JDK10 compiler does not work with "-opt:l:method" on JDK10 Apr 27, 2018
@plokhotnyuk
Copy link

plokhotnyuk commented Apr 27, 2018

I got the same compiler crash on JDK 10 with Scala 2.12.x.

/usr/lib/jvm/jdk-10/bin/java -version
java version "10" 2018-03-20
Java(TM) SE Runtime Environment 18.3 (build 10+46)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10+46, mixed mode)

Sources: https://github.com/plokhotnyuk/jsoniter-scala
Command to reproduce:
sbt -java-home /usr/lib/jvm/jdk-10 -no-colors clean test

It fails with 2.12.4 too, but works fine for 2.11.12:
sbt -java-home /usr/lib/jvm/jdk-10 -no-colors ++2.11.12 clean test

@lrytz
Copy link
Member

lrytz commented May 4, 2018

Just for reference; ASM 6.1.x has an issue that might affect us (https://gitlab.ow2.org/asm/asm/merge_requests/160), which will be fixed only in 6.2

@eed3si9n
Copy link
Member

eed3si9n commented May 6, 2018

On JDK 10 I am getting the same while compiling Zinc, which recently added List("-opt-inline-from:<sources>", "-opt:l:inline", "-Yopt-inline-heuristics:at-inline-annotated") sbt/zinc#492

@mkurz
Copy link

mkurz commented May 30, 2018

ASM 6.2 released with better JDK 10 support and even with JDK 11 support already!
http://asm.ow2.io/versions.html
https://gitlab.ow2.org/asm/asm/tags
https://gitlab.ow2.org/asm/asm/issues/317830

@xuwei-k
Copy link
Author

xuwei-k commented Jun 6, 2018

scala/scala#6733

plokhotnyuk added a commit to plokhotnyuk/jsoniter-scala that referenced this issue Jun 25, 2018
Switch to oraclejdk10 for Scala 2.11.12 only, it doesn't compile for 2.12.6, see scala/bug#10717
@plokhotnyuk
Copy link

@lrytz referenced pr merged to 2.13.x branch only... will it be backported to 2.12.x?

@lrytz
Copy link
Member

lrytz commented Jun 29, 2018

it should be, let's keep this open.

@xuwei-k
Copy link
Author

xuwei-k commented Sep 12, 2018

scala/scala#7089

@xuwei-k
Copy link
Author

xuwei-k commented Jan 19, 2019

FYI, similar issue with JDK12+ #11372

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests