Kotlin / kotlinx.serialization

Kotlin multiplatform / multi-format serialization
Apache License 2.0
5.44k stars 624 forks source link

java.lang.IllegalAccessError when inline class is in different module and Proguard's on #2413

Open 0xffrom opened 1 year ago

0xffrom commented 1 year ago

If the inline class marked @Serializable is in another kotlin module and Proguard is enabled, a java.lang.IllegalAccessError occurs

If Proguard is disabled, no exception occurs: also if the entity is in the same module, no exception occurs.

Log crash: java.lang.IllegalAccessError: Final field 'e.c.b' cannot be written to by method 'java.lang.Object e.a.b(b0.b)' (declaration of 'e.a' appears in /data/app/~~VCTnd_psFPHb6iCMguQ8rg==/github.frosyaX.kotlinX_value_class_sample-sOua_23PZEkNu4nHKj-GrQ==/base.apk)

To Reproduce

A project that reproduces the issue: Android Project

or code:

app-android module

val serializer = SurveyConfig.serializer()
val config = Json.decodeFromString(serializer, """{ "test":  "test"}""")

lib-kotlin module:

@JvmInline
@Serializable
value class SurveyConfig(
    val data: Map<String, String>,
) : Map<String, String> by data 

Also Proguard is enabled

Expected behavior

No-exception behavior

Environment

sandwwraith commented 3 days ago

Hi, is this still reproducible on 1.7.3? We have added a bunch of proguard rules since that.