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

SBT fails to start on the latest JDK-21 builds since build 21 (2023/5/4) #7235

Closed
plokhotnyuk opened this issue May 5, 2023 · 11 comments · Fixed by #7271
Closed

SBT fails to start on the latest JDK-21 builds since build 21 (2023/5/4) #7235

plokhotnyuk opened this issue May 5, 2023 · 11 comments · Fixed by #7271
Labels
area/jdk_x jdk 9, 10, 11, 17 etc Bug
Milestone

Comments

@plokhotnyuk
Copy link

steps

  1. Download and extract jdk-21-ea to /usr/lib/jvm/jdk-21
  2. Run sbt -java-home /usr/lib/jvm/jdk-21

problem

The sbt fails to start with the following error:

[info] [launcher] getting org.scala-sbt sbt 1.9.0-RC1  (this may take some time)...
[info] welcome to sbt 1.9.0-RC1 (Oracle Corporation Java 21-ea)
error:
  bad constant pool index: 0 at pos: 47919
     while compiling: <no file>
        during phase: globalPhase=<no phase>, enteringPhase=<some phase>
     library version: version 2.12.17
    compiler version: version 2.12.17
  reconstructed args: -classpath /home/andriy/.sbt/boot/scala-2.12.17/lib/scala-library.jar -Yrangepos

  last tree to typer: EmptyTree
       tree position: <unknown>
            tree tpe: <notype>
              symbol: null
           call site: <none> in <none>
...

expectation

Normal start

notes

  • Reproducible on both sbt versions 1.8.2 and 1.9.0-RC1
  • Works fine with older jdk-21 builds (build 20 or older)
@plokhotnyuk plokhotnyuk added the Bug label May 5, 2023
@eed3si9n eed3si9n added the area/jdk_x jdk 9, 10, 11, 17 etc label May 5, 2023
@eed3si9n
Copy link
Member

eed3si9n commented May 5, 2023

@plokhotnyuk Thanks for the report! I wonder if Scala 2.12.17 in general works on JDK 21-ea.

@mkurz
Copy link
Member

mkurz commented May 5, 2023

I would guess this fails because Scala 2.12.17 comes with an asm version that does not yet support Java 21.
Upcoming Scala 2.12.18 / 2.13.11 should fix that. See the draft release notes for 2.12.18 for example, mentions Java 20/21 support via asm upgrade: https://github.com/scala/scala-dev/blob/scala-2.12.18/releases/2.12.18.md

plokhotnyuk added a commit to plokhotnyuk/jsoniter-scala that referenced this issue May 6, 2023
@mkurz
Copy link
Member

mkurz commented May 8, 2023

Actually I think it would be good idea to wait for Scala 2.12.18/2.13.11 for the 1.9.0 final release and use that within sbt then...

@cushon
Copy link

cushon commented May 9, 2023

I'm seeing the same bad constant pool index: 0 error with JDK 21 EA builds, with a stack trace like:

	at scala.reflect.internal.Reporting.abort(Reporting.scala:69)
	at scala.reflect.internal.Reporting.abort$(Reporting.scala:65)
	at scala.reflect.internal.SymbolTable.abort(SymbolTable.scala:28)
	at scala.tools.nsc.symtab.classfile.ClassfileParser$ConstantPool.errorBadIndex(ClassfileParser.scala:385)
	at scala.tools.nsc.symtab.classfile.ClassfileParser$ConstantPool.getExternalName(ClassfileParser.scala:249)
	at scala.tools.nsc.symtab.classfile.ClassfileParser.readParamNames$1(ClassfileParser.scala:828)

edit: since the underlying issue is a scala problem, not an sbt problem, I reported it here: scala/bug#12783

@eed3si9n
Copy link
Member

@mkurz

Actually I think it would be good idea to wait for Scala 2.12.18/2.13.11 for the 1.9.0 final release and use that within sbt then...

As far as I know there's no set release date for Scala 2.12.18 since it's waiting on Scala 3.3.0 final, which just released its RC-6 and release thread doesn't mention it, so even with the best case scenario we are like 3 weeks out?
I've discussed this with @adpi2, and we think waiting on this makes things slower than it should be given that we could potentially bump Scala version in a patch release.

@mkurz
Copy link
Member

mkurz commented May 14, 2023

I didn't expect a RC6, but yes, no need to wait. I thought it should be released already... but who knows.

@SethTisue
Copy link
Member

SethTisue commented May 18, 2023

We've published Scala 2.12.18-M2 and Scala 2.13.11-M2 to Maven Central with a fix for scala/bug#12783. You can start sbt on JDK 21 with sbt -Dsbt.scala.version=2.12.18-M2 and it should start up. (Though you might be stymied if you are using plugins such as scoverage that haven't been published for 2.12.18-M2; if so, you'll need to wait for 2.12.18.)

I'll submit the same fix to Scala 3, though it won't make 3.3.0.

(2.12.18 and 2.13.11 will come along not long after Scala 3.3.0 is released.)

@mkurz
Copy link
Member

mkurz commented May 18, 2023

@SethTisue Seems like the M2 git-tags didn't make it upstream? https://github.com/scala/scala/tags

@SethTisue
Copy link
Member

@mkurz oh good call, I didn't think to tag either release. they are tagged now

@SethTisue
Copy link
Member

SethTisue commented Jun 1, 2023

Scala 2.12.18 is on Maven Central (to be announced next week, as per https://contributors.scala-lang.org/t/scala-2-12-18-release-planning/6089/)

eed3si9n added a commit to eed3si9n/sbt that referenced this issue Jun 1, 2023
@eed3si9n eed3si9n added this to the 1.9.0 milestone Jun 1, 2023
@eed3si9n
Copy link
Member

eed3si9n commented Jun 1, 2023

Here's my PR for this - #7271

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/jdk_x jdk 9, 10, 11, 17 etc Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants