2

After upgrading one of my projects to scala 2.13.4 I get the following error:

[error] java.lang.IllegalAccessError: Class 'scala.tools.nsc.transform.patmat.PatternExpansion$ExtractorAlignment' no access to: class 'scala.collection.immutable.LazyList$State'
[error]     at java.base/java.lang.invoke.MethodHandle.sendResolveMethodHandle(MethodHandle.java:1237)
[error]     at java.base/java.lang.invoke.MethodHandle.getCPMethodHandleAt(Native Method)
[error]     at java.base/java.lang.invoke.MethodHandle.getAdditionalBsmArg(MethodHandle.java:935)
[error]     at java.base/java.lang.invoke.MethodHandle.resolveInvokeDynamic(MethodHandle.java:1084)
[error]     at scala.tools.nsc.transform.patmat.PatternExpansion$ExtractorAlignment.fromProductSelectors(PatternExpansion.scala:166)

(full stacktrace is here https://gist.github.com/froth/f4819191644ef6ced0be682ad55f8fa0 as it is quite a long one)

I did not change anything in the code base and I do not actively use LazyList in my project. To complicate things additionally: it works on my machine and fails in the pipeline (same java version, same sbt version(sbt 1.4.4 (AdoptOpenJDK Java 11.0.8)), I cleared all caches).

It is a multiproject build, the top level build.sbt is looking like https://gist.github.com/froth/516c4ea6f8bd98ed87e6a8cadaa117d1 and in the subproject it is the following: https://gist.github.com/froth/03af73900724f47154a0b2477edb47ca

As it is hard to reproduce and it is a internal project with further internal dependencies this is about all I can provide.

My question is: Does anybody know what causes it and what I can do. Or if somebody has ideas how to further debug this or what to try to get more information of what goes wrong.

Frederick Roth
  • 2,748
  • 4
  • 28
  • 42
  • 1
    Can you please share your `build.sbt`? – Tomer Shetah Nov 25 '20 at 07:43
  • linked them above @TomerShetah – Frederick Roth Nov 25 '20 at 07:56
  • 1
    `java.base/java.lang.invoke.MethodHandle` looks like a Java 9+ thing. Can you try to switch to Java 8? https://docs.scala-lang.org/overviews/jdk-compatibility/overview.html#jdk-11-compatibility-notes https://stackoverflow.com/questions/7076414/java-lang-illegalaccesserror-tried-to-access-method – Dmytro Mitin Nov 25 '20 at 11:59
  • 1
    No can't do actually because we have java dependencies that use java9+ features. And I am unsure if this is a general java11 problem as it works in my machine with a java11 setup. – Frederick Roth Nov 25 '20 at 14:43

1 Answers1

2

This could eventually be fixed on our side by upgrading java from 11.0.8 to 11.0.9 (AdoptOpenJDK). Why and how that worked? No idea.

Frederick Roth
  • 2,748
  • 4
  • 28
  • 42
  • We ran in the exact same issue, although a little bit more tricky: sbt was telling us to be using jdk 11.0.10 whereas actually we also had a jdk on 10.0.8 and it turns out that it was actually the one used. Removing that other jdk did the trick. – Antoine Apr 13 '21 at 19:08