MyEnum::valueOf method reference causes crash
Java class file shrinker, optimizer, obfuscator, and preverifier
Brought to you by:
guardsquare
If we have a method reference like this:
MyEnum myEnum = mapper.map(MyEnum::valueOf);
ProGuard will crash with the following message:
Optimizing (pass 3/5)...
Warning: Exception while processing task java.io.IOException: java.lang.IllegalStateException: Expected Utf8Constant at index [22] in class [com/example/proguardtest/MyEnum]
Thread(Tasks limiter_1): destruction
I use the default proguard-android-optimize configuration (attached).
I also created a project where you can reproduce this issue. https://github.com/WonderCsabo/ProguardValueOfBug
Clone, and execute ./gradlew assembleRelease
Thanks for your report and for the helpful sample project. The problem has now been fixed for the upcoming ProGuard 6.1 beta3. For the time being, you can work around it by disabling the optimization of simple enum types:
or by keeping this enum type from being optimized: