Ammonite icon indicating copy to clipboard operation
Ammonite copied to clipboard

java.lang.UnsupportedClassVersionError when running ammonite

Open mdedetrich opened this issue 4 years ago • 10 comments

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 avatar Jul 21 '20 07:07 mdedetrich

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

mdedetrich avatar Jul 22 '20 07:07 mdedetrich

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.

SiegfriedEhret avatar Oct 03 '20 19:10 SiegfriedEhret

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 ;)

simao avatar Jul 19 '21 08:07 simao

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

SethTisue avatar Jul 19 '21 17:07 SethTisue

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?

simao avatar Jul 19 '21 20:07 simao

That also doesn't seem to make any sense

mdedetrich avatar Jul 19 '21 20:07 mdedetrich

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!

simao avatar Jul 19 '21 21:07 simao

The presence of java9rtexport here seems like a crucial clue.

SethTisue avatar Jul 20 '21 00:07 SethTisue

Any update on this ?

jilen avatar May 31 '22 02:05 jilen

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.

alexarchambault avatar Aug 12 '22 17:08 alexarchambault