-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Kotlin data class serialization fails with GraalVM >= 22.1 #28167
Comments
/cc @evanchooly, @geoand |
Unfortunately I can't help much. My understanding is that kotlin tries to reflectively access the caller of the method and fails because reflection is not properly configured. Looking at the error I suspect that you need to register You might also want to run your application with the |
Indeed error disappears if I add reflection config for the Companion object. |
What does the entire |
|
I guess one solution here would be to also automatically register the companion object for data classes. |
Can you try doing:
please? |
Same result :( |
Okay, thanks |
Maybe it is somehow related to Kotlin/kotlinx.serialization#1348 but it really goes beyond my understanding of the compilation process :) More interesting to me is why it is working with some GraalVM versions. |
In this case you are using Jackson, not Kotlin Serialization |
True, but I'm using the compiler plugin which alters the compiled model object |
I am pretty sure that if you remove |
Using newer mandrel image with
How could we do this automatically? |
Thanks for the update!
It would require a change in Quarkus |
Also, fyi. I was testing with Quarkus |
Users have come to expect that @RegisterForReflection fixes a lot of native image issues and use it a lot. For Kotlin classes however, registering a class is often not enough - the companion classes are need to be registered. These companion classes are nested classes, so we automatically set the property to true for Kotlin classes Closes: quarkusio#28167
#29033 should do the trick for automatically setting |
Automatically register nested Kotlin classes for reflection
Users have come to expect that @RegisterForReflection fixes a lot of native image issues and use it a lot. For Kotlin classes however, registering a class is often not enough - the companion classes are need to be registered. These companion classes are nested classes, so we automatically set the property to true for Kotlin classes Closes: quarkusio#28167 (cherry picked from commit 6274863)
Users have come to expect that @RegisterForReflection fixes a lot of native image issues and use it a lot. For Kotlin classes however, registering a class is often not enough - the companion classes are need to be registered. These companion classes are nested classes, so we automatically set the property to true for Kotlin classes Closes: quarkusio#28167
Describe the bug
I'm trying to serialize a Kotlin data class with kotlinx.serialization annotations.
Everything is working as expected with GraalVM 22.0 but starts throwing errors with 22.1 and 22.2.
Data class:
Expected behavior
No error
Actual behavior
Error during serialization.
Stacktrace:
How to Reproduce?
No response
Output of
uname -a
orver
No response
Output of
java -version
17.0.4+8-jvmci-22.2-b06
GraalVM version (if different from Java)
GraalVM 22.2.0 Java 17 CE
Quarkus version or git rev
2.13.0.Final
Build tool (ie. output of
mvnw --version
orgradlew --version
)mvn
Additional information
No response
The text was updated successfully, but these errors were encountered: