Class SWITCH

java.lang.Object
org.apache.bcel.generic.SWITCH
All Implemented Interfaces:
CompoundInstruction

public final class SWITCH extends Object implements CompoundInstruction
SWITCH - Branch depending on int value, generates either LOOKUPSWITCH or TABLESWITCH instruction, depending on whether the match values (int[]) can be sorted with no gaps between the numbers.
  • Constructor Details

    • SWITCH

      public SWITCH(int[] match, InstructionHandle[] targets, InstructionHandle target)
    • SWITCH

      public SWITCH(int[] match, InstructionHandle[] targets, InstructionHandle target, int maxGap)
      Template for switch() constructs. If the match array can be sorted in ascending order with gaps no larger than maxGap between the numbers, a TABLESWITCH instruction is generated, and a LOOKUPSWITCH otherwise. The former may be more efficient, but needs more space. Note, that the key array always will be sorted, though we leave the original arrays unaltered.
      Parameters:
      match - array of match values (case 2: ... case 7: ..., etc.)
      targets - the instructions to be branched to for each case
      target - the default target
      maxGap - maximum gap that may between case branches
  • Method Details