Having a quick look at the PR that added 21 support, it might indeed be there before.
But it was not tested, so they can hardly state previous versions are compatible when they just don’t know.
The JavaDoc also said before:
Not officially supported by Gradle. Use at your own risk.
So if you tested it and it works fine for your use-case, then it is fine.
The PR looks like they just added tests and it just worked.
But that does not mean it worked in previous versions either, just that it works since they added those tests.
before gradle-8.3, the default kotlin-dsl version gave an error and we used:
That is about running Gradle itself with Java 21 which is not even supported with Gradle 8.4.
That’s not the question here, here the question was about using Java 21 toolchain for the production code.
Using a non-matching kotlin-dsl plugin version should usually not be done, this can lead to major problems.
but now, as you say “not supported” i could read out of kotlin that it should support java-21 as jvmTarget. there is stuff removed from java-21, that was deprecated much earlier. and, last but not least, there is the class file format where one could try to play “spot the difference” between java 21 and java 20. thanks for all the hints, @vampire!!
for your second remark, what would be an example problem you refer to when you write “using a non-matching kotlin-dsl plugin versoin can lead to major problems”.
CAUTION:
Avoid specifying a version for the kotlin-dsl plugin
Each Gradle release is meant to be used with a specific version of the kotlin-dsl plugin and compatibility between arbitrary Gradle releases and kotlin-dsl plugin versions is not guaranteed. Using an unexpected version of the kotlin-dsl plugin in a build will emit a warning and can cause hard to diagnose problems.
In Gradle?
That’s irrelevant.
That has nothing to do with Gradle, but purely with Spotbugs or at most the Spotbugs Gradle plugin.
Gradle also has ASM included for some things, but that is totally irrelevant here.
The Spotbugs Gradle Plugin runs Spotbugs in separate processes, because Spotbugs uses some static state which otherwise causes Spotbugs runs even of different projects done withing the same Gradle daemon influencing each other.
So this is more a question to the Spotbugs Gradle plugin, than to a Gradle community.