0

Recently I updated my JDK to JDK 10, and now I get configuration issue with Kotlin and I can't run my code. is this because of JDK 10 or it's because something else?

the hint I get from InteliJ while creating a Kotlin Project:

Configure Kotlin
        Added /Applications/IntelliJ IDEA CE.app/Contents/plugins/Kotlin/kotlinc/lib/kotlin-stdlib-jdk7.jar to library configuration
        Added /Applications/IntelliJ IDEA CE.app/Contents/plugins/Kotlin/kotlinc/lib/kotlin-stdlib-jdk7-sources.jar to library configuration
        Added /Applications/IntelliJ IDEA CE.app/Contents/plugins/Kotlin/kotlinc/lib/kotlin-stdlib-jdk8.jar to library configuration
        Added /Applications/IntelliJ IDEA CE.app/Contents/plugins/Kotlin/kotlinc/lib/kotlin-stdlib-jdk8-sources.jar to library configuration
SinaMN75
  • 6,742
  • 5
  • 28
  • 56
  • 1
    Probably a jdk9+ modules issue. What's the configuration issue you get? What you posted doesn't look like a problem, just information – zapl Sep 29 '18 at 18:15

2 Answers2

2

At the time of writing (Sept. 2018) Kotlin's compiler does not support producing Java 9+ bytecode by default.

The argument -jvm-target 9 (see KT-21959) should make the Kotlin compiler generate bytecode of version 53.

Since Java 10 is bytecode version 54 (reference) - I'm not sure how this will work.

Still:

  • You can compile to the JVM 8 bytecode which can be executed on JVM 9+ normally.

  • If you want to define modules (or use jlink that requires the entire program is modularized) you can write module-info.java files in Java today, and place in the same source root as Kotlin files.

    • The Kotlin compiler will correctly limit the accessibility of declarations in non-exported packages in dependent modules.
    • Currently, there are no plans to support module definitions in Kotlin.

Other than that, most Java 9-11 language features (var, REPL, streams improvements, etc.) - already exist in Kotlin for a while, so the main immediate benefit of using Java 9-11 are using the JVM for the optimizations, or the module system / jlink (which you can use as descrbied above)

Lior Bar-On
  • 10,784
  • 5
  • 34
  • 46
  • I'd like to add there is a currently open issue to let the Kotlin compiler generate .class files with just the version number equal to the established target. This doesn't mean it will use optimized bytecode for that specific version. – LppEdd Sep 29 '18 at 21:35
  • @LppEdd - can you add a link? – Lior Bar-On Sep 29 '18 at 21:39
1

Starting with version 1.3.30 Kotlin now supports JVM bytecode targets 9, 10, 11, 12. (KT-26240 - ticket which LppEdd mentioned - got included.)

StephanS
  • 843
  • 1
  • 8
  • 20