Edoardo Luppi
09/01/2023, 10:39 AMkotlin.jvmToolchain(8)
implies I have a JDK 8 on my machine.
I don't get why an higher JDK (e.g., 17) is not picked up automatically. Is this an expected behavior?hfhbd
09/01/2023, 10:55 AMEdoardo Luppi
09/01/2023, 11:00 AMkotlin.jvm.withJava()
This might mean, besides setting jvmTarget = "1.8"
, I also need to change the target version for the Java compilationshfhbd
09/01/2023, 11:09 AMwithJava
applies the java Gradle plugin. Do you really need this plugin? The Kotlin compiler is able to compile Java source code too. And setting the release option in the JVM toolchain function should be enough, it should set up the Java and Kotlin compiler options correctly.Edoardo Luppi
09/01/2023, 11:13 AMDo you really need this pluginGood question. Not really, I can remove the call. But to understand the error I was getting, take this sample setup
kotlin.jvmToolchain(17)
kotlin.jvm {
withJava()
compilations.configureEach {
kotlinOptions {
jvmTarget = "1.8"
...
With the above you get
> 'compileJava' task (current target is 17) and 'compileKotlinJvm' task (current target is 1.8) jvm target compatibility should be set to the same Java version.
Consider using JVM toolchain: <https://kotl.in/gradle/jvm/toolchain>
Removing withJava
obviously makes it compile correctly.hfhbd
09/01/2023, 11:19 AMEdoardo Luppi
09/01/2023, 11:20 AMVampire
09/01/2023, 12:19 PMjava { toolchain...
, then the Kotlin plugin also picks it up and the tasks are configured consistently.Vampire
09/01/2023, 12:23 PMByteBuffer
methods changed in a binary incompatible way as the return type changed from Buffer
to ByteBuffer
. If you now compile some code that uses these methods with Java 13+ but target Java 8, your classes can run on Java 8 class-version wise, but will fail if the code path that uses those methods is executed as you will get exception about missing method while it works fine on Java 13+.Vampire
09/01/2023, 12:24 PMCLOVIS
09/01/2023, 12:50 PMyou just need to apply one settings plugin that configures where to auto-provision the toolchains from like documented.Can you clarify where that is documented? I've seen people mention this multiple times but I've never seen what exactly needs to be done
Vampire
09/01/2023, 12:51 PMVampire
09/01/2023, 12:52 PMCLOVIS
09/01/2023, 12:54 PMVampire
09/01/2023, 1:35 PMEdoardo Luppi
09/01/2023, 3:48 PM