I have a Play 2.2
app I'm using with Java 8 that I'm having trouble getting to work. The code compiles locally for me using OpenJDK 1.8, but when I try and push the code to Heroku, I get the following error, which was the error I was getting earlier locally when I was running on OpenJDK 1.7 with lambdas by accident.
java.lang.RuntimeException: Unknown constant: 18
I set system.properties
to use Java 1.8 and I know that's working because it's starting up with the following text:
Play 2.x - Java app detected
-----> Installing OpenJDK 1.8...done
Is there something I'm forgetting to do to update to Java 8?
I tried updating the PATH as well as specified here but that didn't do anything.
Unknown constant: 18
most probably refers to CONSTANT_InvokeDynamic
tag in the class file’s constant pool which has the value 18
. This can’t be a JDK issue as even Java 7 understands that tag.
So it is an indicator for a byte code manipulation tool running in your runtime not understanding newer class files (but trying to process them despite the unknown version number). That worked with Java 7 as the invokedynamic
feature exists but is not used with ordinary Java 7 class files (i.e. produced by javac
).
Since you knew if you used bytecode manipulation by yourself, it must be part of a framework, i.e. you named heroku and the playframework. So you problem is not about updating the JDK but updating the frameworks to Java-8-aware versions, if such versions already exist.
As an add-on to Holger's response, here's what Heroku support had to say:
Hi,
Java 8 is still on an old pre-release due to delays on a linux distribution of OpenJDK. You can track the status of JDK 8 here:
https://github.com/heroku/heroku-buildpack-jvm-common/issues/10#issuecomment-38006175