Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /* Soot - a J*va Optimization Framework
  * Copyright (C) 2004 John Jorgensen
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * Library General Public License for more details.
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
package soot.toolkits.exceptions;
import soot.Type;
import soot.Unit;
import soot.Value;
Abstract class implementing parts of the ThrowAnalysis interface which may be common to multiple concrete ThrowAnalysis classes. AbstractThrowAnalysis provides straightforward implementations of mightThrowExplicitly(ThrowInst) and mightThrowExplicitly(ThrowStmt), since concrete implementations of ThrowAnalysis seem likely to differ mainly in their treatment of implicit exceptions.
public abstract class AbstractThrowAnalysis implements ThrowAnalysis {
    abstract public ThrowableSet mightThrow(Unit u);
	Value thrownExpression = t.getOp();
	Type thrownType = thrownExpression.getType();
	if (thrownType == null || thrownType instanceof UnknownType) {
	    // We can't identify the type of thrownExpression, so...
	    return ThrowableSet.Manager.v().;
        } else if (thrownType instanceof NullType) {
            ThrowableSet result = ThrowableSet.Manager.v().;
            result = result.add(ThrowableSet.Manager.v().);
            return result;
else if (! (thrownType instanceof RefType)) {
	    throw new IllegalStateException("UnitThrowAnalysis StmtSwitch: type of throw argument is not a RefType!");
else {
	    ThrowableSet result = ThrowableSet.Manager.v().;
	    if (thrownExpression instanceof NewInvokeExpr) {
		// In this case, we know the exact type of the 
		// argument exception.
		result = result.add((RefTypethrownType);
	    } else {
		result = result.add(AnySubType.v((RefTypethrownType));
	    return result;
    abstract public ThrowableSet mightThrowImplicitly(ThrowStmt t);
New to GrepCode? Check out our FAQ X