001: /* Soot - a J*va Optimization Framework
002: * Copyright (C) 2003 John Jorgensen
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Library General Public
006: * License as published by the Free Software Foundation; either
007: * version 2 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Library General Public License for more details.
013: *
014: * You should have received a copy of the GNU Library General Public
015: * License along with this library; if not, write to the
016: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
017: * Boston, MA 02111-1307, USA.
018: */
019:
020: package soot.toolkits.exceptions;
021:
022: import soot.Unit;
023: import soot.baf.ThrowInst;
024: import soot.jimple.ThrowStmt;
025:
026: /**
027: * <p>A source of information about the exceptions that
028: * {@link Unit}s might throw.</p>
029: *
030: * <p>The <code>Unit</code>s corresponding to <code>athrow</code>
031: * instructions may throw exceptions either explicitly—because
032: * the exception is the <code>athrow</code>'s argument— or
033: * implicitly—because some error arises in the course of
034: * executing the instruction (only implicit exceptions are possible
035: * for bytecode instructions other than <code>athrow</code>). The
036: * <code>mightThrowExplicitly()</code> and
037: * <code>mightThrowImplicitly()</code> methods allow analyses to
038: * exploit any extra precision that may be gained by distinguishing
039: * between an <code>athrow</code>'s implicit and explicit exceptions.</p>
040: */
041:
042: public interface ThrowAnalysis {
043: /**
044: * Returns a set representing the {@link Throwable} types that
045: * the specified unit might throw.
046: *
047: * @param u {@link Unit} whose exceptions are to be returned.
048: *
049: * @return a representation of the <code>Throwable</code> types that
050: * <code>u</code> might throw.
051: */
052: ThrowableSet mightThrow(Unit u);
053:
054: /**
055: * Returns a set representing the {@link Throwable} types that
056: * the specified throw instruction might throw explicitly, that is,
057: * the possible types for its <code>Throwable</code> argument.
058: *
059: * @param t {@link ThrowInst} whose explicit exceptions are
060: * to be returned.
061: *
062: * @return a representation of the possible types of
063: * <code>t</code>'s <code>Throwable</code> operand.
064: */
065: ThrowableSet mightThrowExplicitly(ThrowInst t);
066:
067: /**
068: * Returns a set representing the {@link Throwable} types that
069: * the specified throw statement might throw explicitly, that is,
070: * the possible types for its <code>Throwable</code> argument.
071: *
072: * @param t {@link ThrowStmt} whose explicit exceptions are
073: * to be returned.
074: *
075: * @return a representation of the possible types of
076: * <code>t</code>'s <code>Throwable</code> operand.
077: */
078: ThrowableSet mightThrowExplicitly(ThrowStmt t);
079:
080: /**
081: * Returns a set representing the {@link Throwable} types that
082: * the specified throw instruction might throw implicitly, that is,
083: * the possible types of errors which might arise in the course
084: * of executing the <code>throw</code> instruction, rather than
085: * the type of the <code>throw</code>'s operand.
086: *
087: * @param t {@link ThrowStmt} whose implicit exceptions are
088: * to be returned.
089: *
090: * @return a representation of the types of exceptions that
091: * <code>t</code> might throw implicitly.
092: */
093: ThrowableSet mightThrowImplicitly(ThrowInst t);
094:
095: /**
096: * Returns a set representing the {@link Throwable} types that
097: * the specified throw statement might throw implicitly, that is,
098: * the possible types of errors which might arise in the course
099: * of executing the <code>throw</code> statement, rather than
100: * the type of the <code>throw</code>'s operand.
101: *
102: * @param t {@link ThrowStmt} whose implicit exceptions are
103: * to be returned.
104: *
105: * @return a representation of the types of exceptions that
106: * <code>t</code> might throw implicitly.
107: */
108: ThrowableSet mightThrowImplicitly(ThrowStmt t);
109:
110: }
|