spring-projects / spring-framework

Spring Framework
https://spring.io/projects/spring-framework
Apache License 2.0
56.34k stars 38.02k forks source link

Introduce `KotlinUtils` #33630

Open sdeleuze opened 2 days ago

sdeleuze commented 2 days ago

Kotlin support has grown organically both in Spring Framework and other Spring portfolio projects, the set of features required portfolio wide is now pretty stabilized but there is a lack of reuse with related maintainability challenges.

For example, the logic Kotlin logic in InvocableHandlerMethod is involved, duplicated on WebFlux side, and required on Spring Boot side for features like configuration property binding to a Kotlin value class as described in https://github.com/spring-projects/spring-boot/issues/41693.

Spring Data has a also lot of Kotlin related infrastructure that could be shared as well.

mp911de commented 1 day ago

Spring Data has a set of utils (KotlinReflectionUtils, KotlinBeanInfoFactory, KotlinValueUtils) for various applications, such as value class usage and Property descriptor detection. Would it make sense to move some of these into Spring Framework to let other components also benefit from Value classes?

sdeleuze commented 1 day ago

@mp911de The functional scope of those utils make sense to me, we may end up to refine some public API and implementation, especially if we are able to move forward on #21546 and collaborate closely with Kotlin team to simplify value class support and fix some bug you have reported like https://youtrack.jetbrains.com/issue/KT-20768. If that's ok for you I will have a deeper look to Spring Data Kotlin utils, and include related learnings in my discussion with the Kotlin team, and when we have a reasonably clear idea of the underlying capabilities we will use, we can start collaborating actively on that.