All Downloads are FREE. Search and download functionalities are using the official Maven repository.

soot.toolkits.exceptions.PedanticThrowAnalysis Maven / Gradle / Ivy

package soot.toolkits.exceptions;

/*-
 * #%L
 * Soot - a J*va Optimization Framework
 * %%
 * Copyright (C) 2003 John Jorgensen
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 2.1 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Lesser Public License for more details.
 * 
 * You should have received a copy of the GNU General Lesser Public
 * License along with this program.  If not, see
 * .
 * #L%
 */

import soot.G;
import soot.Singletons;
import soot.Unit;
import soot.baf.ThrowInst;
import soot.jimple.ThrowStmt;

/**
 * A {@link ThrowAnalysis} that says that every unit can throw every possible exception type. Strictly speaking, this is
 * correct, since the deprecated {@link java.lang.Thread#stop(Throwable)} method allows one thread to cause any
 * {@link Throwable} it wants to be thrown in another thread, meaning that all {@link Throwable}s may arrive asynchronously
 * from the perspective of the victim thread.
 */
public class PedanticThrowAnalysis extends AbstractThrowAnalysis {

  /**
   * Constructs a PedanticThrowAnalysis for inclusion in Soot's global variable manager, {@link G}.
   *
   * @param g
   *          guarantees that the constructor may only be called from {@link Singletons}.
   */
  public PedanticThrowAnalysis(Singletons.Global g) {
  }

  /**
   * Returns the single instance of PedanticThrowAnalysis.
   *
   * @return Soot's PedanticThrowAnalysis.
   */
  public static PedanticThrowAnalysis v() {
    return G.v().soot_toolkits_exceptions_PedanticThrowAnalysis();
  }

  /**
   * Returns the set of all Throwables as the set of types that the specified unit might throw, regardless of
   * the unit's identity.
   *
   * @param u
   *          {@link Unit} whose exceptions are to be returned.
   *
   * @return the set of all Throwables.
   */
  public ThrowableSet mightThrow(Unit u) {
    return ThrowableSet.Manager.v().ALL_THROWABLES;
  }

  /**
   * Returns the set of all Throwables as the set of types that a throw instruction may throw
   * implicitly, that is, the possible types of errors which might arise in the course of executing the throw
   * instruction, rather than the type of the throw's operand.
   *
   * @param t
   *          the {@link ThrowInst} whose exceptions are to be returned.
   *
   * @return the set of all Throwables.
   */
  public ThrowableSet mightThrowImplicitly(ThrowInst t) {
    return ThrowableSet.Manager.v().ALL_THROWABLES;
  }

  /**
   * Returns the set of all Throwables as the set of types that a throw statement may throw
   * implicitly, that is, the possible types of errors which might arise in the course of executing the throw
   * statement, rather than the type of the throw's operand.
   *
   * @param t
   *          the {@link ThrowStmt} whose exceptions are to be returned.
   *
   * @return the set of all Throwables.
   */
  public ThrowableSet mightThrowImplicitly(ThrowStmt t) {
    return ThrowableSet.Manager.v().ALL_THROWABLES;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy