class WrapSwitchesInTrys extends BodyTransformer implements IJbcoTransform {

  int totaltraps = 0;

  public static String dependancies[] = new String[] { "bb.jbco_ptss", "bb.jbco_ful", "bb.lp" };

  public String[] getDependencies() {
    return dependancies;
  }

  public static String name = "bb.jbco_ptss";

  public String getName() {
    return name;
  }

  public void outputSummary() {
    out.println("Switches wrapped in Tries: " + totaltraps);
  }

  protected void internalTransform(Body b, String phaseName, Map<String, String> options) {<FILL_FUNCTION_BODY>}
}

    int weight = soot.jbco.Main.getWeight(phaseName, b.getMethod().getSignature());
    if (weight == 0) {
      return;
    }

    int i = 0;
    Unit handler = null;
    Chain<Trap> traps = b.getTraps();
    PatchingChain<Unit> units = b.getUnits();
    Iterator<Unit> it = units.snapshotIterator();
    while (it.hasNext()) {
      Unit u = (Unit) it.next();
      if (u instanceof TableSwitchInst) {
        TableSwitchInst twi = (TableSwitchInst) u;

        if (!BodyBuilder.isExceptionCaughtAt(units, twi, traps.iterator()) && Rand.getInt(10) <= weight) {
          if (handler == null) {
            Iterator<Unit> uit = units.snapshotIterator();
            while (uit.hasNext()) {
              Unit uthrow = (Unit) uit.next();
              if (uthrow instanceof ThrowInst && !BodyBuilder.isExceptionCaughtAt(units, uthrow, traps.iterator())) {
                handler = uthrow;
                break;
              }
            }

            if (handler == null) {
              handler = Baf.v().newThrowInst();
              units.add(handler);
            }
          }

          int size = 4;
          Unit succ = (Unit) units.getSuccOf(twi);
          while (!BodyBuilder.isExceptionCaughtAt(units, succ, traps.iterator()) && size-- > 0) {
            Object o = units.getSuccOf(succ);
            if (o != null) {
              succ = (Unit) o;
            } else {
              break;
            }
          }

          traps.add(Baf.v().newTrap(ThrowSet.getRandomThrowable(), twi, succ, handler));
          i++;
        }
      }
    }

    totaltraps += i;
    if (i > 0 && debug) {
      StackTypeHeightCalculator.calculateStackHeights(b);
    }
  
<methods>public non-sealed void <init>() ,public final void transform(soot.Body, java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(soot.Body, java.lang.String) ,public final void transform(soot.Body) <variables>private static final Map<java.lang.String,java.lang.String> enabledOnlyMap