class DexTrapStackFixer extends BodyTransformer {

  public static DexTrapStackFixer v() {
    return new DexTrapStackFixer();
  }

  @Override
  protected void internalTransform(Body b, String phaseName, Map<String, String> options) {
    for (Trap t : b.getTraps()) {
      // If the first statement already catches the exception, we're fine
      if (isCaughtExceptionRef(t.getHandlerUnit())) {
        continue;
      }

      // Add the exception reference
      Local l = Scene.v().createLocalGenerator(b).generateLocal(t.getException().getType());
      Stmt caughtStmt = Jimple.v().newIdentityStmt(l, Jimple.v().newCaughtExceptionRef());
      b.getUnits().add(caughtStmt);
      b.getUnits().add(Jimple.v().newGotoStmt(t.getHandlerUnit()));
      t.setHandlerUnit(caughtStmt);
    }
  }

  /**
   * Checks whether the given statement stores an exception reference
   *
   * @param handlerUnit
   *          The statement to check
   * @return True if the given statement stores an exception reference, otherwise false
   */
  private boolean isCaughtExceptionRef(Unit handlerUnit) {<FILL_FUNCTION_BODY>}

}

    if (!(handlerUnit instanceof IdentityStmt)) {
      return false;
    }
    IdentityStmt stmt = (IdentityStmt) handlerUnit;
    return stmt.getRightOp() instanceof CaughtExceptionRef;
  
<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