Checking whether a class is a Kotlin data class would be useful. For example, we might want to use different binder (mapper) by the kind of the target class. Here's a comment that wants a way to detect: https://github.com/spring-projects/spring-batch/issues/4568#issuecomment-2098441363
I found that BindingReflectionHintsRegistrar
uses KClass#isData()
only when a type is Kotlin type:
https://github.com/spring-projects/spring-framework/blob/df238d08eb8355b4e57c95fdea8faf1913651924/spring-core/src/main/java/org/springframework/aot/hint/BindingReflectionHintsRegistrar.java#L223-L224
I think that this pattern would be useful when provided as an utility function like:
// false if the specified class is not a Kotlin type
// if the specified class is a Kotlin type, returns by KotlinDelegate using JvmClassMappingKt
public static boolean isKotlinDataClass(Class<?> clazz) {
// ...
}
Comment From: sdeleuze
KotlinDetector
is designed to allow fast detection without having to load kotlin-reflect
which can be more heavy, and I plan to introduce extended related capabilities via #21546 kotlinx-metadata-jvm
when a Kotlin 2.0 baseline will be used, as a consequence I decline this issue.