Menu

#744 MyEnum::valueOf method reference causes crash

v6.0
closed-fixed
None
Medium
2019-05-14
2019-03-21
WonderCsabo
No

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

1 Attachments

Discussion

  • Eric Lafortune

    Eric Lafortune - 2019-04-14

    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:

    -optimizations !class/unboxing/enum
    

    or by keeping this enum type from being optimized:

    -keep,allowshrinking,allowobfuscation enum com.example.proguardtest.MyEnum
    
     
  • Eric Lafortune

    Eric Lafortune - 2019-04-14
    • status: open --> open-fixed
    • assigned_to: Eric Lafortune
     
  • Eric Lafortune

    Eric Lafortune - 2019-05-14
    • Status: open-fixed --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB