Add support for Kotlin inline classes [DATACMNS-1517]
See original GitHub issueWyatt Smith opened DATACMNS-1517 and commented
Here is an example with the bug: https://github.com/wyattjsmith1/SpringDataBug
When this runs, there is an IndexOutOfBoundsException
. This is caused by kotlin’s synthetic constructor. I believe the issues is that synthetic constructors aren’t filtered before.
buildPreferredConstructor
at org.springframework.data.mapping.model.PreferredConstructorDiscoverer.Discoverers#discover
, but there is probably a better solution to this.
Changing AccountId in the data class to a String
causes the application to work properly. Admittedly, inline classes are still experimental for Kotlin, but this might be worth investigating
Issue Links:
- DATAGRAPH-1330 Properties with type of Kotlin inline class has mangled name
7 votes, 10 watchers
Issue Analytics
- State:
- Created 4 years ago
- Reactions:26
- Comments:14 (3 by maintainers)
Top Results From Across the Web
Inline classes | Kotlin
Inline classes support some functionality of regular classes. ... functions using inline classes are mangled by adding some stable hashcode ...
Read more >Store Kotlin inline class to MongoDB with Spring Data
I'm using a workaround for this, by introducing a private field. inline class UserId(@NotBlank val id: String = UUID.randomUUID().
Read more >How to Enable Kotlin 1.3 Inline Classes Today
Include Kotlin support if you're in Android Studio. Walk through the rest of the setup wizard. 3. Add the repository. The Kotlin build...
Read more >spring-projects/spring-data - Gitter
Is there something I can do to make kotlin inline classes work with Spring Data Mongo (Reactive) on my side? There's an issue...
Read more >ArrayIndexOutOfBoundsException when using inline class as ...
From https://jira.spring.io/browse/DATACMNS-1517: When this runs, there is an IndexOutOfBoundsException. This is caused by kotlin's synthetic constructor. I ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi, i am user using spring data with kotlin. Any progress on this?
Answered my own question, thanks to https://github.com/spring-projects/spring-data-commons/issues/2215#issuecomment-752410346. I was using unsigned types. Changing them to
Int
made the issue go away.