Skip to content

Clarification on Kotlin support #44651

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jxblum opened this issue Mar 7, 2025 · 9 comments
Closed

Clarification on Kotlin support #44651

jxblum opened this issue Mar 7, 2025 · 9 comments
Labels
status: declined A suggestion or change that we don't feel we should currently apply

Comments

@jxblum
Copy link
Contributor

jxblum commented Mar 7, 2025

Hello Spring Boot team-

While I am aware of the System Requirements and Kotlin Support documentation, I am wondering whether I am missing more specific details on Kotlin supported versions.

As mentioned in Requirements, "Spring Boot requires at least Kotlin 1.7.x...".

Technically, Spring Boot seems to use a Kotlin 1.9.x baseline, and specifically 1.9.25 (here as applied here).

Would it be advisable to call out supported Kotlin versions in System Requirements in the same manner as Spring Boot does for Java, having a baseline of Java 17, but compatible up to and including Java 23?

For example:

"Spring Boot is based on Kotlin 1.9.x (err... 1.7.x?), currently 1.9.25, but is compatible with versions up to and including Kotlin 2.0.x."

NOTE: JetBrains has currently released Kotlin 2.0.21 in 2.0.x, and 2.1.10 in 2.1.x.

I am quite certain Spring Boot will work with Kotlin 2.0.21 and likely even 2.1.x. I already have some examples of using Kotlin 2.0.21 with Spring Boot in the work I am doing, but I feel that some sort of reassurance from the Spring Boot team, probably having done the testing effort to assert compatibility with Kotlin 2.0.x, maybe even 2.1.x, would definitely cement users early confidence.

WDYT?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 7, 2025
@jxblum
Copy link
Contributor Author

jxblum commented Mar 7, 2025

To provide a bit more context:

I recently came across issues with Detekt, which I am finding is quite commonly used across Kotlin projects and teams.

Versioning becomes really important when using certain Kotlin tools, like Detekt, that are strictly coupled with the Kotlin compiler version, even at the patch-level, no less. :( See the Compatibility Table.

I have experienced errors like this even between patch versions 1.9.23 and 1.9.25.

As you can see, Detekt has a version based on 1.9.23, but not 1.9.25. While Detekt clearly does not follow semver, and the Detekt team seems to have their reasons, as you can imagine, this does complicate things.

To be clear, I am not expecting the stars to align between disparate projects, but that the path to resolution is more clear.

I am currently in the process of making an early decision to base Kotlin projects, for which I am partly responsible for, on Kotlin 2.0.21 and preserve our strong interest in Spring Boot, hence my ask in this ticket.

@jxblum
Copy link
Contributor Author

jxblum commented Mar 7, 2025

DISCLAIMER: I am still learning and have a lot to learn in the Kotlin space.

@jxblum
Copy link
Contributor Author

jxblum commented Mar 7, 2025

Another quick questions...

I feel pretty confident in saying that (asking if) Spring Boot's next significant (e.g. major) version bump of Kotlin (i.e. 2.x) will likely occur in Spring Boot 4?

@dmitrysulman
Copy link
Contributor

I am quite certain Spring Boot will work with Kotlin 2.0.21 and likely even 2.1.x.

I can confirm that Spring Boot 3.4.x works perfectly with Kotlin 2.0.x and 2.1.x. We have multiple services in Kotlin 2.1.10 + Spring Boot 3.4.2 running in production.

I feel pretty confident in saying that (asking if) Spring Boot's next significant (e.g. major) version bump of Kotlin (i.e. 2.x) will likely occur in Spring Boot 4?

Yes, it will.

@wilkinsona
Copy link
Member

Saying that Spring Boot requires at least 1.7.x is accurate as the small amount of Kotlin code that we have is compiled with the API version and language version set to 1.7. Beyond this, we rely on Kotlin's compatibility across versions.

We have CI for several different versions of Java and make a stronger statement about supported versions of a result. We don't have any plans to do the same for Kotlin. We have very little Kotlin code and I don't recall any bugs being reported regarding version compatibility. The benefits of that CI would be outweighed by the cost of setting it up and maintaining it.

Lastly, our Kotlin requirements are largely driven by those of Spring Framework.

All in all, I think we've said about as much as we can about the required version of Kotlin so I'm going to close this one. @sdeleuze do you have any plans on the Framework side to make a strong statement about the version requirements or to expand testing to cover multiple versions of Kotlin?

@wilkinsona wilkinsona closed this as not planned Won't fix, can't repro, duplicate, stale Mar 10, 2025
@wilkinsona wilkinsona added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 10, 2025
@sdeleuze
Copy link
Contributor

+1 to what @wilkinsona said.

We try to keep an extended compatibility of 2 minor releases before the Kotlin version used for compilation and test because this is what the Kotlin team claims to support.

I don't know in details Detekt, but based on my quick read of its documentation it seems to be implemented as a Kotlin compiler plugin which is known to be very fragile, hence the fact JetBrains and Google advise to use https://github.com/google/ksp instead. Spring does not implement a Kotlin compiler plugin, so the versioning constraints are more flexible for us.

As you may have noticed, in practice it is mostly possible to run Spring Boot with Kotlin 2.0/2.1, but you need to manually downgrade the potential Kotlin Serialization / Kotlin Coroutines versions used, and there may be issues at Gradle plugin support level, hence the fact we don't claim/deny explicitly compatibility.

Spring Framework 7 and Spring Boot 4 are expected to provide most tested / first class support for Kotlin 2 (with a Kotlin 2.2 baseline).

@jxblum
Copy link
Contributor Author

jxblum commented Mar 10, 2025

Thank you for sharing your thoughts and position @wilkinsona and @sdeleuze. Makes good sense.

@jxblum
Copy link
Contributor Author

jxblum commented Mar 10, 2025

Thank you for sharing your experience @dmitrysulman.

@jxblum
Copy link
Contributor Author

jxblum commented Mar 10, 2025

Lastly, Detekt is more similar to SpotBugs or PMD for Java in function and purpose (OOTB) than any annotation/symbol processing tool (or even a general Linter, like Ktlint). I only learned about Detekt recently, and haven't found a suitable replacement based on its capabilities and our use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

No branches or pull requests

5 participants