You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To mitigate such issues, functions using inline classes are mangled by adding some stable hashcode to the function name. Therefore, fun compute(x: UInt) will be represented as public final void compute-(int x), which solves the clash problem.
Spring Data fails to parse findSomeEntityById function with the following error:
Failed to create query for method public abstract java.util.Optional dev.d1s.test.repository.SomeEntityRepository.findSomeEntityById-956swU4(java.lang.String)! Unable to locate Attribute with the the given name [id-956swU4]
Currently, I can solve such a problem by adding the @JvmName annotation:
But I find this quite problematic to include these two annotations every single time on every single repository method consuming Kotlin's inline class.
IMO, there is a way to tolerate function mangling. You can simply detect it and cut off the hashcode part from the method name.
The text was updated successfully, but these errors were encountered:
Kotlin's inline-class mechanism randomizes any method names that touch the surface of inline classes. We have the ticket #1947 to address inline classes support so closing this one as duplicate. We also see that Kotlin's approach is less than ideal as it invalidates all assumptions made by frameworks that rely on property names and property paths.
From the Kotlin documentation:
Look at the following code:
Spring Data fails to parse
findSomeEntityById
function with the following error:Currently, I can solve such a problem by adding the
@JvmName
annotation:But I find this quite problematic to include these two annotations every single time on every single repository method consuming Kotlin's inline class.
IMO, there is a way to tolerate function mangling. You can simply detect it and cut off the hashcode part from the method name.
The text was updated successfully, but these errors were encountered: