https://kotlinlang.org logo
#kotest
Title
# kotest
b

Benni

02/13/2022, 6:22 PM
Hey folks, (I am new to the channel and I hope this is the right place to ask). I am getting this exception when running Kotest on a gradle travis-ci build but not when I run it on my local mac book:
Copy code
UnknownClass.Kotest > UnknownClass.initializationError FAILED
    java.lang.UnsupportedClassVersionError at ClassLoader.java:-2
(see log here). I am using Kotlin 1.6.2 and Kotest 5.10 (see versions here) I am a little unclear how to debug this and any pointers are greatly appreciated.
r

Richard Gomez

02/13/2022, 6:28 PM
What version of Java are you using on your mac vs on travis?
UnsupportedClassVersionError
would usually imply some sort of JDK mis-match. 🤔
s

sam

02/13/2022, 6:31 PM
Yep, you prob need JDK11+
b

Benni

02/13/2022, 6:33 PM
Hi Richard and Sam. My local installation is
Copy code
openjdk 11.0.14 2022-01-18 LTS
OpenJDK Runtime Environment Corretto-11.0.14.9.1 (build 11.0.14+9-LTS)
OpenJDK 64-Bit Server VM Corretto-11.0.14.9.1 (build 11.0.14+9-LTS, mixed mode)
And I think my travis build is jdk 11 too (see config). But I’ll see if I can get more info about travis java installation.
r

Richard Gomez

02/13/2022, 6:33 PM
Odd, it should be using 11.
Copy code
language: kotlin
jdk:
  - oraclejdk11
(Aside: is there a reason you're using oraclejdk11 and not openjdk11? Most people avoid oracle's JDK for fear of future license issues.)
s

sam

02/13/2022, 6:34 PM
You might have something that is using > 11
Kotest itself is compiled with jdk8, so it works for everyone, but I suspect some library you are using in your test is itself compiled with > 11. https://github.com/kotest/kotest/blob/master/.github/workflows/master.yml#L22-L26
b

Benni

02/13/2022, 6:36 PM
Do you think which class could not be loaded is actually not in the error message. I assumed is is the actual class
Kotest
. But maybe that is not correct.
is there a reason you’re using oraclejdk11 and not openjdk11
no, no reason. I think I might have copied it carelessly. Thanks for the feedback. I’ll can change it 🙂
s

sam

02/13/2022, 6:37 PM
Kotest is trying to launch your test, that error is being throw and then kotest is dumping out that message. It should give you more details but I suspect somewhere in kotest we don't handle
Throwable
but only
Exception
and that is an
Error
so you don't get much details.
r

Richard Gomez

02/13/2022, 6:38 PM
@Benni Can you run the job with
--stacktrace
or
--debug
? There's not much info to glean from the default verbosity level. e.g. this error has the detailed message in the stacktrace but not the 'message'. https://github.com/kotest/kotest/issues/2785
s

sam

02/13/2022, 6:40 PM
Also in addition to what @Richard Gomez said, if you add these steps to your github actions workflow, it will upload the entire test report as an artifact and you will see the full stack trace (probably)
Copy code
-  name: Bundle the build report
   if: failure()
   run: find . -type d -name 'reports' | zip -@ -r build-reports.zip

-  name: Upload the build report
   if: failure()
   uses: actions/upload-artifact@master
   with:
      name: error-report
      path: build-reports.zip
b

Benni

02/13/2022, 6:49 PM
okay. I think I figured it out and it has nothing to do with kotest. The offending class comes actually from the project itself. Here is what happens: 1. Project classes are getting compiled with JDK 11 2. I am using kotlinx kover coder coverage and for some reason that starts a jdk 8 vm:
Copy code
/usr/lib/jvm/java-8-openjdk-amd64/bin/java -Dcoverage.ignore.private.constructor.util.class=true -Didea.coverage.log.level=error -Didea.new.sampling.coverage=true -Didea.new.tracing.coverage=true -...
This seems like a bug or misconfiguration of kover tool
Thanks Sam and Richard for being patient and pointing me to “have you tried turning on debug logs” 🙂
😂 1
s

sam

02/13/2022, 6:54 PM
nice catch
If you get kover working and have time, open up a PR for docs on Kotest!
r

Richard Gomez

02/13/2022, 6:57 PM
I've wasted a lot of time troubleshooting misleading error messages with Maven and Gradle. 😢
s

sam

02/13/2022, 6:57 PM
Yes gradle is awful for that
b

Benni

02/14/2022, 12:17 AM
okay. I think I figured it out. I need to add jdk 11 explicitly: https://docs.travis-ci.com/user/languages/java/#switching-jdks-to-java-10-and-up-within-one-job
38 Views