I know this question was asked gzillions of times already, but I am specifically after a decompiler that would handle enums corrently (because the jar I am decompiling uses enums heavily). I tested that both JAD and JD-GUI don't.
Could someone recommend a decompiler (ideally that works under Linux and can easily handle the whole jar without requiring me to write shell scrips)?
EDIT: Specifically I have issues with constructs like:
switch(myEnum) {
case A: ...
case B: ...
}
they get decompiled (for both JAD and JD-GUI) as something like:
switch ($SWITCH_TABLE$com$MyType()[myEnum.ordinal()]) {
case 1:
case 2:
}
where $SWITCH_TABLE$com$MyType()
is either not declared at all or doesn't compile.
It is not possible to decompile a enum-switch properly. The java-classfile doesn't know about the enum-Typ after compilation, thus your decompiler cant decompile it as you like it.
Enums-Types are all a subtype of java.lang.Enum
, every enum constant got an ordinal-number which is used in a switch statement. The compiler do a switch on that int-value, a switch over an enum type is simply said syntactic-sugar. If you try to switch on an null
-enum you will get a NPE.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With