Does Kotlin support Java 11?

The bytecode generated by the Kotlin compiler, when the target version is set to either 1.6 or 1.8, is fully compatible with JVM 11.


The Kotlin compiler supports the JVM 9, 10, 11, and 12 bytecode versions as target since Kotlin 1.3.30 (changelog).

Prior to 1.3.30, only JVM 1.6 and 1.8 bytecode versions were supported as targets. Since you used 1.2.70, specifying JVM 11 bytecode as target led to the error you mentioned.

There are two solutions:

  • Specify 1.8 as JVM target bytecode version. As @yole said in his answer, this is fully compatible with JVM 11. In fact, as mentioned in the changelog of Kotlin 1.3.30, newer JVM target bytecode versions currently don't add any bytecode optimizations beyond the ones supported in 1.8, so it really doesn't make any difference for now anyway.

  • Upgrade to Kotlin 1.3.30 (or newer), then you can keep 11 as the JVM bytecode target value. The advantage is that you will automatically benefit from additional bytecode optimizations in future versions of the Kotlin compiler.

Tags:

Jvm

Gradle

Kotlin