Kotlin enum class in Android performance-ThrowExceptions

Exception or error:

In Java we are told to strictly avoid using enums on Android because they take up twice the memory.

Does this apply to enum class in Kotlin aswell? Will a Kotlin enum be compiled into a Java enum?

How to solve:

It would appear so, yes.

I created this in Kotlin:

enum class Thingies {

And decompiled it with javap -v, and here is the header:

public final class Thingies extends java.lang.Enum<Thingies>
minor version: 0
major version: 52

Bottom line: they are identical, so you probably have to treat them the same way.


They are exactly the same thing, a Kotlin Enum is a Java JVM Enum.


You can most definitely use enums in Android now, they specifically discussed this topic in this Google I/O video: https://www.youtube.com/watch?v=IrMw7MEgADk
(if you don’t want to watch the whole video, then start from 11:30 ish to 14:40).

Leave a Reply

Your email address will not be published. Required fields are marked *