how are enum classes implemented on the JVM? do th...
# announcements
p
how are enum classes implemented on the JVM? do they produce code that’s similar to a java
enum
? asking because i’m trying to figure out how swagger annotations work and if i can rename them
r
I’m 99% sure they are the same as Java enums when compiled. If you’re using IntelliJ you can view Kotlin bytecode and the decompile it to Java to check it out.
p
how do i view the bytecode / decompile to java? i’m using bazel and not sure if it makes any difference
z
Yes, kotlin enums are the same thing as java enums.
If you’re using IntelliJ, hit ctrl+shift+a and type “show kotlin bytecode”
1
p
on a related note, is it possible to override the string rep (bidirectional) for an enum?
i can’t write my enum like
SOLE-PROP
because
-
is invalid but in my API that’s being autogenerated i want it to have a hyphen
z
enums can have constructor params and properties, and you can store whatever data you like and implement
toString
yourself.
If you’re serializing/deserializing, you’ll have to consult the documentation for the library you’re using to determine how to override names