-
Notifications
You must be signed in to change notification settings - Fork 620
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
Serializing emptyMap()
throws IllegalAccessException
#2449
Comments
Java's integrity checks strike: we should avoid reflective accesses to the classes from |
This also brings the question, is it legitimate for the intrinsic to kick in here on the interface (without |
Which JVM version are you running on? |
@sandwwraith it is in the initial report: Java Temurin 17.0.4. |
…ializer for some private implementation classes from stdlib. Fixes #2449
I've had a look at the code. What is going on is that this code is trying to determine whether the type is a Kotlin object by reading the static While While the error message is far from clear it is not clear that this code should be correct (should it return Another aspect is that due to java reflection, this triggers While the example is a bit silly, the use case I see occurring is where there is a value that needs to be serialized based on its dynamic type (there are good reasons you may not want to do this, but nevertheless quite some web frameworks do this). Thinking to do that requires some way to get the member type (and it serializer) which is way too involved (common base types, polymorphic serialization,...), so a framework would need to do that itself. But in the end we are running against the nature of kotlinx.serialization being based on static serialization. As to the use case, it would be better to use a special |
Describe the bug
Calling
kotlinx.serialization.serializerOrNull(emptyMap<String, String>().javaClass)
causesTo Reproduce
Expected behavior
Serializer able to serialize
emptyMap()
into{}
is returned.Environment
The text was updated successfully, but these errors were encountered: