Skip to content

[BUG] Default proguard rules may contain error #3775

@OfficialKatana

Description

@OfficialKatana

This is the error that I'd encountered:

Exception in thread "main" java.lang.ExceptionInInitializerError
        at a.a(Unknown Source)
        at uC.<init>(Unknown Source)
        at uz.a(Unknown Source)
        at main(Unknown Source)
Caused by: java.lang.RuntimeException: java.lang.NoSuchFieldException: chars
        at java.base/java.util.concurrent.atomic.AtomicReferenceFieldUpdater$AtomicReferenceFieldUpdaterImpl.<init>(AtomicReferenceFieldUpdater.java:334)
        at java.base/java.util.concurrent.atomic.AtomicReferenceFieldUpdater.newUpdater(AtomicReferenceFieldUpdater.java:112)
        at f.<clinit>(Unknown Source)
        ... 4 more
Caused by: java.lang.NoSuchFieldException: chars
        at java.base/java.lang.Class.getDeclaredField(Class.java:2384)
        at java.base/java.util.concurrent.atomic.AtomicReferenceFieldUpdater$AtomicReferenceFieldUpdaterImpl.<init>(AtomicReferenceFieldUpdater.java:328)
        ... 6 more

And these are the rules that I'd added

-keepclassmembers class com.alibaba.fastjson2.JSONFactory$CacheItem {<fields>;}
-keepclassmembers class com.alibaba.fastjson2.util.TypeUtils$Cache {<fields>;}

I think that the document should be updated. These are the optimized proguard rules

-keepclassmembers class com.alibaba.fastjson2.JSONFactory$CacheItem {<fields>;}
-keepclassmembers class com.alibaba.fastjson2.util.TypeUtils$Cache {<fields>;}
-keep, allowoptimization, allowobfuscation @com.alibaba.fastjson2.annotation.JSONType class *
# Keep the fields and methods with @JSONField
-keepclassmembers, allowobfuscation class * {
  @com.alibaba.fastjson2.annotation.JSONField <fields>;
  @com.alibaba.fastjson2.annotation.JSONField <methods>;
}

# Keep any (anonymous) classes extending TypeReference
-keep, allowobfuscation class com.alibaba.fastjson2.TypeReference
-keep, allowobfuscation class * extends com.alibaba.fastjson2.TypeReference

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions