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

java.lang.UnsupportedClassVersionError when running ammonite #1107

Closed
mdedetrich opened this issue Jul 21, 2020 · 10 comments · Fixed by #1319
Closed

java.lang.UnsupportedClassVersionError when running ammonite #1107

mdedetrich opened this issue Jul 21, 2020 · 10 comments · Fixed by #1319
Milestone

Comments

@mdedetrich
Copy link

mdedetrich commented Jul 21, 2020

OS: Manjaro Linux (latest stable)
Ammonite Version: Welcome to the Ammonite Repl 2.1.4 (Scala 2.13.2 Java 11.0.7)
Ammonite Package: https://www.archlinux.org/packages/community/any/ammonite/ (official ammonite package on Archlinux)
JDK: openjdk 11.0.7 2020-04-14 ; OpenJDK Runtime Environment (build 11.0.7+10) ; OpenJDK 64-Bit Server VM (build 11.0.7+10, mixed mode)
which java: /usr/bin/java

When running ammonite locally with an empty cache (i.e. ~/.ammonite is wiped) using amm I am getting

java.lang.UnsupportedClassVersionError: io/github/retronym/java9rtexport/Export has been compiled by a more recent version of the Java Runtime (class file version 57.0), this version of the Java Runtime only recognizes class file versions up to 55.0
  ammonite.runtime.Classpath$.classpath(Classpath.scala:77)
  ammonite.interp.CompilerLifecycleManager.init(CompilerLifecycleManager.scala:85)
  ammonite.interp.CompilerLifecycleManager.preprocess(CompilerLifecycleManager.scala:57)
  ammonite.interp.Interpreter.$anonfun$processLine$4(Interpreter.scala:247)
  ammonite.util.Res$Success.flatMap(Res.scala:62)
  ammonite.interp.Interpreter.$anonfun$processLine$2(Interpreter.scala:240)
  ammonite.util.Catching.flatMap(Res.scala:115)
  ammonite.interp.Interpreter.processLine(Interpreter.scala:239)
  ammonite.repl.Repl.$anonfun$action$8(Repl.scala:197)
  ammonite.util.Res$Success.flatMap(Res.scala:62)
  ammonite.repl.Repl.$anonfun$action$4(Repl.scala:184)
  ammonite.repl.Scoped.$anonfun$flatMap$1(Signaller.scala:45)
  ammonite.repl.Signaller.apply(Signaller.scala:28)
  ammonite.repl.Scoped.flatMap(Signaller.scala:45)
  ammonite.repl.Scoped.flatMap$(Signaller.scala:45)
  ammonite.repl.Signaller.flatMap(Signaller.scala:16)
  ammonite.repl.Repl.$anonfun$action$2(Repl.scala:176)
  ammonite.util.Catching.flatMap(Res.scala:115)
  ammonite.repl.Repl.action(Repl.scala:168)
  ammonite.repl.Repl.loop$1(Repl.scala:208)
  ammonite.repl.Repl.run(Repl.scala:223)
  ammonite.Main.$anonfun$run$1(Main.scala:223)
  scala.Option.getOrElse(Option.scala:201)
  ammonite.Main.run(Main.scala:211)
  ammonite.MainRunner.$anonfun$runRepl$1(Main.scala:413)
  ammonite.MainRunner.watchLoop(Main.scala:394)
  ammonite.MainRunner.runRepl(Main.scala:413)
  ammonite.Main$.main0(Main.scala:320)
  ammonite.Main$.main(Main.scala:270)
  ammonite.Main.main(Main.scala)

Note that this happens not immediately on startup but when I first start interacting with the repl (i.e. even pressing enter on a blank new line).

@mdedetrich
Copy link
Author

Bug on archlinux is here https://bugs.archlinux.org/task/67353 (incase its not upstream issue).

@SiegfriedEhret
Copy link

I am getting the same thing with Java 11.0.8.
I switched to others with archlinux-java, and everything works fine with Java 1.8.0_265 or 14.0.2.

@simao
Copy link

simao commented Jul 19, 2021

This is a problem with packaging upstream. the package binary is built with java 1.8 and if you then run it with java 1.11 you will get this error. You can build the package with jvm 1.11 using:

java -version # make sure you are using java 1.11, you can set this with  `archlinux-java set`
mkdir amm
cd amm
curl -O https://raw.githubusercontent.com/archlinux/svntogit-community/packages/ammonite/trunk/PKGBUILD
makepkg -i

Of course at this point maybe it's just easier to use the amm script in this repo ;)

@SethTisue
Copy link

Why would Java 11 complain about Java 8 classfiles? The other way around would make sense...

@simao
Copy link

simao commented Jul 19, 2021

Possibly I got this wrong and the package was compiled with a jvm version > than 11, but somehow works on jvm 8 but not 11?

@mdedetrich
Copy link
Author

That also doesn't seem to make any sense

@simao
Copy link

simao commented Jul 19, 2021

Well, sometimes things that don't make sense actually happen:

With ammonite compiled with java 16:

~ ❯ amm
Loading...
Welcome to the Ammonite Repl 2.4.0 (Scala 2.13.2 Java 16.0.1)
@  

@  

@ Bye!
~ ❯ sudo archlinux-java set java-11-openjdk
~ ❯ amm
Loading...
Welcome to the Ammonite Repl 2.4.0 (Scala 2.13.2 Java 11.0.11)
@  
java.lang.UnsupportedClassVersionError: io/github/retronym/java9rtexport/Export has been compiled by a more recent version of the Java Runtime (class file version 60.0), this version of the Java Runtime only recognizes class file versions up to 55.0
  ammonite.util.Classpath$.classpath(Classpath.scala:76)
  ammonite.compiler.CompilerLifecycleManager.init(CompilerLifecycleManager.scala:92)
  ammonite.compiler.CompilerLifecycleManager.preprocess(CompilerLifecycleManager.scala:64)
  ammonite.interp.Interpreter.$anonfun$processLine$4(Interpreter.scala:260)
  ammonite.util.Res$Success.flatMap(Res.scala:62)
  ammonite.interp.Interpreter.$anonfun$processLine$2(Interpreter.scala:253)
  ammonite.util.Catching.flatMap(Res.scala:115)
  ammonite.interp.Interpreter.processLine(Interpreter.scala:252)
  ammonite.repl.Repl.$anonfun$action$8(Repl.scala:199)
  ammonite.util.Res$Success.flatMap(Res.scala:62)
  ammonite.repl.Repl.$anonfun$action$4(Repl.scala:186)
  ammonite.repl.Scoped.$anonfun$flatMap$1(Signaller.scala:45)
  ammonite.repl.Signaller.apply(Signaller.scala:28)
  ammonite.repl.Scoped.flatMap(Signaller.scala:45)
  ammonite.repl.Scoped.flatMap$(Signaller.scala:45)
  ammonite.repl.Signaller.flatMap(Signaller.scala:16)
  ammonite.repl.Repl.$anonfun$action$2(Repl.scala:178)
  ammonite.util.Catching.flatMap(Res.scala:115)
  ammonite.repl.Repl.action(Repl.scala:170)
  ammonite.repl.Repl.loop$1(Repl.scala:212)
  ammonite.repl.Repl.run(Repl.scala:227)
  ammonite.Main.$anonfun$run$1(Main.scala:232)
  scala.Option.getOrElse(Option.scala:201)
  ammonite.Main.run(Main.scala:220)
  ammonite.MainRunner.$anonfun$runRepl$1(Main.scala:425)
  ammonite.MainRunner.watchLoop(Main.scala:406)
  ammonite.MainRunner.runRepl(Main.scala:425)
  ammonite.Main$.main0(Main.scala:331)
  ammonite.Main$.main(Main.scala:279)
  ammonite.Main.main(Main.scala)


@ Bye!
~ ❯ sudo archlinux-java set java-8-openjdk
~ ❯ amm
Loading...
Welcome to the Ammonite Repl 2.4.0 (Scala 2.13.2 Java 1.8.0_292)
@  


@  

@  
@ Bye!

@SethTisue
Copy link

The presence of java9rtexport here seems like a crucial clue.

@jilen
Copy link

jilen commented May 31, 2022

Any update on this ?

@alexarchambault
Copy link
Collaborator

Any update on this ?

That seems to be specific to Arch Linux. Someone running Arch Linux should probably pick it up, and fix it or find a workaround.

felixonmars added a commit to felixonmars/Ammonite that referenced this issue Jan 29, 2023
lefou pushed a commit that referenced this issue Jan 30, 2023
@lefou lefou added this to the after 2.5.6 milestone Jan 30, 2023
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

Successfully merging a pull request may close this issue.

7 participants