Vineflower / vineflower

Modern Java decompiler aiming to be as accurate as possible, with an emphasis on output quality. Fork of the Fernflower decompiler.
https://vineflower.org/
Apache License 2.0
1.24k stars 88 forks source link

Unable to simplify switch on enum from BinExport2Reader.class #403

Open rohitab opened 3 months ago

rohitab commented 3 months ago

Vineflower version

1.10.1

Describe the bug

Here is the relevant section from the decompiled version of BinExport2Reader.class. Please see the comment tagged $VF.

// $VF: Unable to simplify switch on enum
// Please report this to the Vineflower issue tracker, at https://github.com/Vineflower/vineflower/issues with a copy of the class file (if you have the rights to distribute it!)
private static EJumpType toJumpType(com.google.security.zynamics.BinExport.BinExport2.FlowGraph.Edge.Type var0) {
  switch (1.$SwitchMap$com$google$security$zynamics$BinExport$BinExport2$FlowGraph$Edge$Type[var0.ordinal()]) {
     case 1:
        return EJumpType.JUMP_TRUE;
     case 2:
        return EJumpType.JUMP_FALSE;
     case 3:
        return EJumpType.UNCONDITIONAL;
     case 4:
        return EJumpType.SWITCH;
     default:
        throw new IllegalArgumentException("Invalid flow graph edge type");
  }
}

Additional information

You can extract BinExport2Reader.class from the attached archive BinExport2Reader.class.zip.

It's from BinDiff version 8. The source code for the class is available in BinExport2Reader.java. You can download the complete software from the BinDiff releases page.