On 4/4/20 12:12 AM, Akim Demaille wrote:
The JVMs are known to be quite good at optimizing, but I have no idea whether 
this abstraction will be zero-cost or not.

Although I'm no Java expert, a quick bit of Googling suggests that JVMs don't deal with enums quite as efficently as they do with ints. See, for example:

https://developer.android.com/topic/performance/reduce-apk-size

which says: "Avoid enumerations. A single enum can add about 1.0 to 1.4 KB of size to your app's classes.dex file. These additions can quickly accumulate for complex systems or shared libraries. If possible, consider using the @IntDef annotation and code shrinking to strip enumerations out and convert them to integers. This type conversion preserves all of the type safety benefits of enums."

Have you considered using @IntDef instead?

Reply via email to