Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does proguard converts all enums to int or needs to be configured for this

Does proguard automatically converts enums to integer for memory optimization or I have to configure it to do this? If I do have to configure what is the configuration?

like image 621
karma Avatar asked Aug 26 '15 21:08

karma


People also ask

Is it possible to convert an enum to an integer?

Some standard methods implicitly convert enum value to integer, as shown in the following code. If the enum is extensible, this generates a warning to the effect " Cast from extensible enum 'Extensible Enumeration (EnumType)' to 'int' potentially harmful and deprecated. " Has anyone encountered this previously? How did you address the warning?

Should I use enum2int instead of enumparameter?

Well, the enumParameter property will anyway use int value, so there is no additional risk in using enum2int vs not using it in this scenario. Makes sense. I was worried since this was an extensible enum.

How does ProGuard reduce the size of native libraries?

The size of native libraries is not impacted by the operation either. But ProGuard managed to drastically reduce the code size by a factor of 3, and the package size and download size have been reduced by one-third. Good job! :-) This post provides a practical example of applying Proguard to a real-life application.

What's new in ProGuard?

-addconfigurationdebugging, a runtime tool used to determine the rules you’ll require in your ProGuard configuration. The new ProGuard Playground online tool, which lets you see the impact of a set of keep rules on the target application. This replaces long build and analyze cycles with immediate visualization.


1 Answers

The optimization is listed on ProGuard's optimizations page. It appears to be one of the default optimizations, but it (like other optimizations) can be specified explicitly if you need more control (e.g. disabling all class/* optimizations aside from enum unboxing).

class/unboxing/enum

Simplifies enum types to integer constants, whenever possible.

like image 195
Jeff Bowman Avatar answered Oct 02 '22 12:10

Jeff Bowman