Skip to content
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

compilation error with JVM 20 #1204

Open
yanns opened this issue Jun 13, 2023 · 6 comments
Open

compilation error with JVM 20 #1204

yanns opened this issue Jun 13, 2023 · 6 comments

Comments

@yanns
Copy link

yanns commented Jun 13, 2023

steps

By updating the JVM from 19 to OpenJDK20U-jre_x64_linux_hotspot_20.0.1_9
with scala 2.13.11
and sbt 1.9.0

problem

we have a new compilation error:

[error] scala.reflect.internal.MissingRequirementError: object java.lang.Object in compiler mirror not found.
[error] scala.reflect.internal.MissingRequirementError$.notFound(MissingRequirementError.scala:24)
[error] scala.reflect.internal.Mirrors$RootsBase.$anonfun$getModuleOrClass$6(Mirrors.scala:63)
[error] scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:63)
[error] scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:55)
[error] scala.reflect.internal.Mirrors$RootsBase.getRequiredClass(Mirrors.scala:55)
[error] scala.reflect.internal.Definitions$DefinitionsClass.ObjectClass$lzycompute(Definitions.scala:293)
[error] scala.reflect.internal.Definitions$DefinitionsClass.ObjectClass(Definitions.scala:293)
[error] scala.reflect.internal.Definitions$DefinitionsClass.init(Definitions.scala:1654)
[error] scala.tools.nsc.Global$Run.<init>(Global.scala:1249)
[error] xsbt.ZincCompiler$ZincRun.<init>(CallbackGlobal.scala:80)
[error] xsbt.CachedCompiler0.run(CompilerBridge.scala:161)
[error] xsbt.CachedCompiler0.run(CompilerBridge.scala:134)
[error] xsbt.CompilerBridge.run(CompilerBridge.scala:39)
[error] sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$7(MixedAnalyzingCompiler.scala:193)
[error] scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error] sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:248)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:183)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:163)
[error] sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:163)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:211)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:534)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:534)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$5(Incremental.scala:179)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$5$adapted(Incremental.scala:177)
[error] sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:463)
[error] sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:116)
[error] sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:56)
[error] sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:52)
[error] sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:263
@adpi2
Copy link
Member

adpi2 commented Jun 16, 2023

I was not able to reproduce the issue:

$ eval $(cs java --jvm adoptium:1.20.0.1 --env)
$ sbt                                          
[info] welcome to sbt 1.9.0 (Eclipse Adoptium Java 20.0.1)
[info] loading global plugins from /home/piquerez/.sbt/1.0/plugins
[info] loading project definition from /home/piquerez/github/sbt/sbt-1204/project
[info] loading settings for project sbt-1204 from build.sbt ...
[info] set current project to sbt-1204 (in build file:/home/piquerez/github/sbt/sbt-1204/)
[info] sbt server started at local:///home/piquerez/.sbt/1.0/server/f27c1efd1ebeb2b494be/sock
[info] started sbt server
sbt:sbt-1204> compile
[info] compiling 1 Scala source to /home/piquerez/github/sbt/sbt-1204/target/scala-2.13/classes ...
[success] Total time: 2 s, completed Jun 16, 2023, 11:45:11 AM

I tried switching from adoptium:1.19.0.2 to adoptium:1.20.0.1 in some of my complex build and it worked fine.

@yanns do you have some more precise reproduction instructions (repo, OS, steps)?

@yanns
Copy link
Author

yanns commented Jun 18, 2023

It's an internal application.
OS:

System information:
 Server Version: 20.10.18
 Storage Driver: overlay2
  Backing Filesystem: xfs
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Kernel Version: 5.15.0-1030-aws
 Operating System: Ubuntu 20.04.5 LTS
 OSType: linux
 Architecture: x86_64

JVM installed with jabba:

jabba install "20.0-custom=tgz+https://github.com/adoptium/temurin20-binaries/releases/download/jdk-20.0.1%2B9/OpenJDK20U-jre_x64_linux_hotspot_20.0.1_9.tar.gz"

I found the issue. There was the following option in build.sbt:

ThisBuild / scalacOptions ++= Seq("-release", "11")

Using the following produces the same issue:

ThisBuild / scalacOptions ++= Seq("-release", "12")

@yanns
Copy link
Author

yanns commented Jun 18, 2023

I'll try with other release values later.

@adpi2 adpi2 self-assigned this Jun 19, 2023
@yanns
Copy link
Author

yanns commented Jun 27, 2023

when looking at https://docs.scala-lang.org/overviews/compiler-options/index.html, the flag release does not seem to support JVM 20:

-release RELEASE or --release RELEASE
Compile for a specific version of the Java platform. Supported targets: 6, 7, 8, 9

The documentation might be outdated as I can use the values 11 and 12.
Do you maybe know which values are possible?

@adpi2
Copy link
Member

adpi2 commented Jul 4, 2023

I found the issue. There was the following option in build.sbt:

ThisBuild / scalacOptions ++= Seq("-release", "11")

I still cannot reproduce the issue though.

Could it be an issue in the compiler itself? Can you try running coursier launch scalac:2.13.11 -- HelloWorld.scala -release 12?

Do you maybe know which values are possible?

According to this line it supports all versions from 8 to 21.

@vasilmkd
Copy link
Contributor

vasilmkd commented Aug 7, 2023

This error looks similar to the error when the old Scala compilers are executed with newer JDK versions (9+) that do not have a proper rt.jar.

Sbt has solved this by running their bespoke java9-rt-export.jar (https://github.com/sbt/java9-rt-export) and then providing the output path via -Dscala.ext.dirs.

@adpi2 adpi2 removed their assignment Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants