class TrapTightener extends TrapTransformer {
  private static final Logger logger = LoggerFactory.getLogger(TrapTightener.class);

  protected ThrowAnalysis throwAnalysis = null;

  public TrapTightener(Singletons.Global g) {
  }

  public static TrapTightener v() {
    return soot.G.v().soot_toolkits_exceptions_TrapTightener();
  }

  public TrapTightener(ThrowAnalysis ta) {
    this.throwAnalysis = ta;
  }

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

  /**
   * A utility routine which determines if a particular {@link Unit} might throw an exception to a particular {@link Trap},
   * according to the information supplied by a particular control flow graph.
   *
   * @param g
   *          The control flow graph providing information about exceptions.
   * @param u
   *          The unit being inquired about.
   * @param t
   *          The trap being inquired about.
   * @return <tt>true</tt> if <tt>u</tt> might throw an exception caught by <tt>t</tt>, according to <tt>g</tt.
   */
  protected boolean mightThrowTo(ExceptionalUnitGraph g, Unit u, Trap t) {
    for (ExceptionDest dest : g.getExceptionDests(u)) {
      if (dest.getTrap() == t) {
        return true;
      }
    }
    return false;
  }
}

    if (this.throwAnalysis == null) {
      this.throwAnalysis = Scene.v().getDefaultThrowAnalysis();
    }

    if (Options.v().verbose()) {
      logger.debug("[" + body.getMethod().getName() + "] Tightening trap boundaries...");
    }

    Chain<Trap> trapChain = body.getTraps();
    Chain<Unit> unitChain = body.getUnits();
    if (trapChain.size() > 0) {
      ExceptionalUnitGraph graph = ExceptionalUnitGraphFactory.createExceptionalUnitGraph(body, throwAnalysis);
      Set<Unit> unitsWithMonitor = getUnitsWithMonitor(graph);

      for (Iterator<Trap> trapIt = trapChain.iterator(); trapIt.hasNext();) {
        Trap trap = trapIt.next();
        boolean isCatchAll = trap.getException().getName().equals(Scene.v().getBaseExceptionType().toString());
        Unit firstTrappedUnit = trap.getBeginUnit();
        Unit firstTrappedThrower = null;
        Unit firstUntrappedUnit = trap.getEndUnit();
        Unit lastTrappedUnit = unitChain.getPredOf(firstUntrappedUnit);
        Unit lastTrappedThrower = null;
        for (Unit u = firstTrappedUnit; u != null && u != firstUntrappedUnit; u = unitChain.getSuccOf(u)) {
          if (mightThrowTo(graph, u, trap)) {
            firstTrappedThrower = u;
            break;
          }

          // If this is the catch-all block and the current unit has
          // an,
          // active monitor, we need to keep the block
          if (isCatchAll && unitsWithMonitor.contains(u)) {
            if (firstTrappedThrower == null) {
              firstTrappedThrower = u;
            }
            break;
          }
        }
        if (firstTrappedThrower != null) {
          for (Unit u = lastTrappedUnit; u != null; u = unitChain.getPredOf(u)) {
            // If this is the catch-all block and the current unit
            // has an, active monitor, we need to keep the block
            if (mightThrowTo(graph, u, trap) || (isCatchAll && unitsWithMonitor.contains(u))) {
              lastTrappedThrower = u;
              break;
            }
          }
        }
        // If no statement inside the trap can throw an exception, we
        // remove the complete trap.
        if (firstTrappedThrower == null) {
          trapIt.remove();
        } else {
          if (firstTrappedThrower != null && firstTrappedUnit != firstTrappedThrower) {
            trap.setBeginUnit(firstTrappedThrower);
          }
          if (lastTrappedThrower == null) {
            lastTrappedThrower = firstTrappedUnit;
          }
          if (lastTrappedUnit != lastTrappedThrower) {
            trap.setEndUnit(unitChain.getSuccOf(lastTrappedThrower));
          }
        }
      }
    }
  
<methods>public non-sealed void <init>() ,public Set<soot.Unit> getUnitsWithMonitor(soot.toolkits.graph.UnitGraph) <variables>