square / moshi

A modern JSON library for Kotlin and Java.
https://square.github.io/moshi/1.x/
Apache License 2.0
9.78k stars 761 forks source link

Classes annotated with @JsonClass(generateAdapter = true) are not obfuscated #1834

Open sanjeevirajm opened 7 months ago

sanjeevirajm commented 7 months ago

Expected behaviour - Classes annotated with @JsonClass(generateAdapter = true) no longer uses reflection, Class name and package name will be obfuscated by default when R8 is enabled.

Actual behaviour - Class members are obfuscated but class name and package remains same.

Dependencies version - implementation 'com.squareup.retrofit2:retrofit:2.9.0' implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0' implementation "com.squareup.retrofit2:converter-moshi:2.9.0"

implementation "com.squareup.moshi:moshi:1.13.0"
ksp "com.squareup.moshi:moshi-kotlin-codegen:1.13.0"

Kotlin and gradle tools version - tried in multiple versions, got the same result

Proguard rule from my side - no additional rule is added

JakeWharton commented 7 months ago

no longer uses reflection

The generated adapters do not use reflection. However, in order to discover the adapters at runtime, they are looked up reflectively. There is simply no other choice for this, unless you want to manually register each generated adapter with your Moshi.Builder.

implementation 'com.squareup.retrofit2:retrofit:2.9.0' implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0' implementation "com.squareup.retrofit2:converter-moshi:2.9.0"

Unrelated, but align those versions!