[BUG] Default proguard rules may contain error
- Dominant language
- Java
- Stars
- 4.4k
- Forks
- 613
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 6
Description
This is the error that I'd encountered:
```
Exception in thread "main" java.lang.ExceptionInInitializerError
at a.a(Unknown Source)
at uC.(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.(AtomicReferenceFieldUpdater.java:334)
at java.base/java.util.concurrent.atomic.AtomicReferenceFieldUpdater.newUpdater(AtomicReferenceFieldUpdater.java:112)
at f.(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.(AtomicReferenceFieldUpdater.java:328)
... 6 more
```
And these are the rules that I'd added
```
-keepclassmembers class com.alibaba.fastjson2.JSONFactory$CacheItem {;}
-keepclassmembers class com.alibaba.fastjson2.util.TypeUtils$Cache {;}
```
I think that the document should be updated. These are the optimized proguard rules
```
-keepclassmembers class com.alibaba.fastjson2.JSONFactory$CacheItem {;}
-keepclassmembers class com.alibaba.fastjson2.util.TypeUtils$Cache {;}
-keep, allowoptimization, allowobfuscation @com.alibaba.fastjson2.annotation.JSONType class *
# Keep the fields and methods with @JSONField
-keepclassmembers, allowobfuscation class * {
@com.alibaba.fastjson2.annotation.JSONField ;
@com.alibaba.fastjson2.annotation.JSONField ;
}
# Keep any (anonymous) classes extending TypeReference
-keep, allowobfuscation class com.alibaba.fastjson2.TypeReference
-keep, allowobfuscation class * extends com.alibaba.fastjson2.TypeReference
```
Contributor guide
Research direction
Start by reproducing the reported ExceptionInInitializerError with the default and optimized ProGuard rules shown in the issue. Compare those rules with the documentation and determine whether the default configuration causes the missing chars field; done means the rules or documentation accurately prevent or explain the failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100