#141 ProGuard and enums

Some sunny day
open
None
3
2014-05-06
2013-08-18
Wanderer
No

The similar topic was already discussed here: http://sourceforge.net/p/proguard/feature-requests/84/

The problem is: each enum class contains "hidden" string literals with field names, and ProGuard doesn't touch them in the obfuscation stage.

My suggestion is to add a new per-class configuration option, something like "clear-string-literals". If you specify one for a enum class in your project, ProGuard simply replaces all string literals in that class with "" (empty string).

Such option would be perfect for obfuscating enums which are not being used as full-fledges classes, but simply for switching and iterating purposes. Of course one should be careful with that option because it would clear all "regular" string literals in your enum as well.

I've investigated it a bit, and it looks like enum's string literals are not being used anywhere in runtime library; enum's valueOf() and toString() methods aren't being used either. Classes like EnumMap and EnumSet, however, require enum's values() static method to work, but clearing string literals doesn't affect their functionality either.

Thanks in advance!

Regards,
Wanderer

Discussion

  • Eric Lafortune

    Eric Lafortune - 2013-08-19

    Thanks for the suggestion. I'm always very reluctant to add more options, especially options that can so easily break the code and cause confusion. Proper optimization of enums is in the pipeline though.

     
  • Eric Lafortune

    Eric Lafortune - 2013-08-19
    • assigned_to: Eric Lafortune
    • Priority: 5 --> 3
     
  • Wanderer

    Wanderer - 2013-08-20

    No worries, I do realize that my suggestion was sort of "dirty hack".

    If you come with a better solution regarding enums, that's only better. Thanks again for your work, Eric!

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks