Skip to content
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

Add isKotlinDataClass to KotlinDetector #32937

Closed
0x1306e6d opened this issue Jun 2, 2024 · 1 comment
Closed

Add isKotlinDataClass to KotlinDetector #32937

0x1306e6d opened this issue Jun 2, 2024 · 1 comment
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: declined A suggestion or change that we don't feel we should currently apply theme: kotlin An issue related to Kotlin support

Comments

@0x1306e6d
Copy link
Contributor

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: spring-projects/spring-batch#4568 (comment)

I found that BindingReflectionHintsRegistrar uses KClass#isData() only when a type is Kotlin type:

KClass<?> kClass = JvmClassMappingKt.getKotlinClass(type);
if (kClass.isData()) {

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) {
    // ...
}
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jun 2, 2024
@jhoeller jhoeller added in: core Issues in core modules (aop, beans, core, context, expression) theme: kotlin An issue related to Kotlin support labels Jun 2, 2024
@sdeleuze sdeleuze self-assigned this Jun 3, 2024
@sdeleuze
Copy link
Contributor

sdeleuze commented Jun 3, 2024

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.

@sdeleuze sdeleuze closed this as not planned Won't fix, can't repro, duplicate, stale Jun 3, 2024
@sdeleuze sdeleuze 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 or decided on labels Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: declined A suggestion or change that we don't feel we should currently apply theme: kotlin An issue related to Kotlin support
Projects
None yet
Development

No branches or pull requests

4 participants