there was some time ago some discussion regarding ...
# language-evolution
g
there was some time ago some discussion regarding kotlin lts versioning or something similar. We currently have the issue where we want to update the jdk to 27 which was released 2 months ago but cant because we need 2.5 released. We will use the RC version due to the RCE but are there any plans to make this update more seamless? Currently JDK releases new version and we wait couple of months for the new kotlin version to support it.
c
Why can’t you? You can run Kotlin code on JDK 27 with no issues
g
we try to keep the build and runtime on the same version, mostly due to that
Copy code
kotlin {
    jvmToolchain(27)
    compilerOptions {
        apiVersion.set(KotlinVersion.KOTLIN_2_5)
        jvmTarget.set(JvmTarget.JVM_27)
    }
}
this wont work for example with kotlin 2.4.1
m
Sorry, but what exactly won’t work? Is it because you’re seeing errors from the Kotlin Gradle plugin like:
Copy code
Inconsistent JVM Target Compatibility Between Java and Kotlin Tasks
?
g
Copy code
plugins {
    `jvm-test-suite`
    `java-test-fixtures`
    java
    kotlin("jvm") version "2.4.21"
    alias(libs.plugins.sentry)
    alias(libs.plugins.detekt)
    alias(libs.plugins.shadow)
    alias(libs.plugins.kotest)
    alias(libs.plugins.spotless)
}

kotlin {
    jvmToolchain(27)

    compilerOptions {
        apiVersion.set(KotlinVersion.KOTLIN_2_5)
        jvmTarget.set(JvmTarget.JVM_27)
    }
}
we get the following
Copy code
* What went wrong:
Script compilation errors:

  Line 29:         jvmTarget.set(JvmTarget.JVM_27)
                                           ^ Unresolved reference 'JVM_27'.

  Line 55:             jvmTarget.set(JvmTarget.JVM_27)
                                               ^ Unresolved reference 'JVM_27'.
the enum essentially does not have the value
gradle 9.9.0 fyi
m
Right, but the JVM target only sets the classfile version. The only visible effect is that the produced classfiles won’t run on older JVMs. Other than that, you can use newer JDK API if you need it or just run on a newer JVM.
g
i see, thanks. so should we just rely on the jvmtoolchain?
m
Yes, jvmToolchain is fine. Note that you’ll get an error from the Kotlin Gradle plugin, but that can be adjusted with
kotlin.jvm.target.validation.mode=warning
flag in gradle.properties. And it’s something that we should be probably adjust on our side
✅ 1
g
thanks a lot