Slackbot
09/06/2023, 7:07 AMephemient
09/06/2023, 7:36 AMplugins {
`java-library`
kotlin("jvm")
}
val java11 by sourceSets.creating {
java.source(sourceSets.main.get().java)
kotlin.source(sourceSets.main.get().kotlin)
resources.source(sourceSets.main.get().resources)
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
registerFeature("java11") {
usingSourceSet(java11)
}
}
tasks.named<JavaCompile>("compileJava11Java") {
javaCompiler.set(javaToolchains.compilerFor {
languageVersion.set(JavaLanguageVersion.of(11))
})
}
tasks.named<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>("compileJava11Kotlin") {
kotlinJavaToolchain.toolchain.use(javaToolchains.launcherFor {
languageVersion.set(JavaLanguageVersion.of(11))
})
}Vampire
09/06/2023, 7:51 AMEli Graber
09/06/2023, 10:58 AMephemient
09/06/2023, 11:00 AMBuffer.flip overloads in Java versions past 11 unless you're actually using JDK 11 (or equivalent with --release)ephemient
09/06/2023, 11:02 AMephemient
09/06/2023, 11:03 AMVampire
09/06/2023, 11:18 AMByteBuffer methods was in 13ephemient
09/06/2023, 11:25 AMVampire
09/06/2023, 11:31 AM--release should actually mitigate the problem.
But the question is still, why one should want to do that.Vampire
09/06/2023, 11:32 AMposition. I wasn't aware of that.
In Java 13 there were more such breaking changes like flip and some more.Vampire
09/06/2023, 11:33 AM-release so you can compile against the target API version. This was there before JVM toolchains feature and could be used. But nowadays I'd prefer to just set the proper toolchain version.