use of soot.toolkits.exceptions.ExceptionTestUtility.ExceptionHashSet in project soot by Sable.
the class UnitThrowAnalysisTest method testJExitMonitorStmt.
@Test
public void testJExitMonitorStmt() {
Stmt s = Jimple.v().newExitMonitorStmt(StringConstant.v("test"));
Set expectedRep = new ExceptionHashSet(utility.VM_ERRORS);
expectedRep.add(utility.ILLEGAL_MONITOR_STATE_EXCEPTION);
expectedRep.add(utility.NULL_POINTER_EXCEPTION);
assertTrue(ExceptionTestUtility.sameMembers(expectedRep, Collections.EMPTY_SET, unitAnalysis.mightThrow(s)));
Set expectedCatch = new ExceptionHashSet(utility.VM_ERRORS_PLUS_SUPERTYPES);
expectedCatch.add(utility.ILLEGAL_MONITOR_STATE_EXCEPTION);
expectedCatch.add(utility.NULL_POINTER_EXCEPTION);
expectedCatch.add(utility.RUNTIME_EXCEPTION);
expectedCatch.add(utility.EXCEPTION);
assertEquals(expectedCatch, utility.catchableSubset(unitAnalysis.mightThrow(s)));
}
use of soot.toolkits.exceptions.ExceptionTestUtility.ExceptionHashSet in project soot by Sable.
the class UnitThrowAnalysisTest method testGThrowStmt.
@Test
public void testGThrowStmt() {
ThrowStmt s = Grimp.v().newThrowStmt(Grimp.v().newLocal("local0", RefType.v("java.util.zip.ZipException")));
Set expectedRep = new ExceptionHashSet(utility.PERENNIAL_THROW_EXCEPTIONS);
expectedRep.add(AnySubType.v(Scene.v().getRefType("java.util.zip.ZipException")));
assertTrue(ExceptionTestUtility.sameMembers(expectedRep, Collections.EMPTY_SET, unitAnalysis.mightThrow(s)));
Set expectedCatch = new ExceptionHashSet(utility.PERENNIAL_THROW_EXCEPTIONS_PLUS_SUPERTYPES);
// We don't need to add java.util.zip.ZipException, since it is not
// in the universe of test Throwables.
assertEquals(expectedCatch, utility.catchableSubset(unitAnalysis.mightThrow(s)));
// Now throw a new IncompatibleClassChangeError.
s = Grimp.v().newThrowStmt(Grimp.v().newNewInvokeExpr(utility.INCOMPATIBLE_CLASS_CHANGE_ERROR, Scene.v().makeMethodRef(utility.INCOMPATIBLE_CLASS_CHANGE_ERROR.getSootClass(), "void <init>", Collections.EMPTY_LIST, VoidType.v(), false), new ArrayList()));
assertTrue(ExceptionTestUtility.sameMembers(utility.THROW_PLUS_INCOMPATIBLE_CLASS_CHANGE, Collections.EMPTY_SET, unitAnalysis.mightThrow(s)));
assertEquals(utility.THROW_PLUS_INCOMPATIBLE_CLASS_CHANGE_PLUS_SUPERTYPES, utility.catchableSubset(unitAnalysis.mightThrow(s)));
// Throw a local of type IncompatibleClassChangeError.
Local local = Grimp.v().newLocal("local1", utility.INCOMPATIBLE_CLASS_CHANGE_ERROR);
s.setOp(local);
expectedRep = new ExceptionHashSet(utility.PERENNIAL_THROW_EXCEPTIONS);
expectedRep.remove(utility.INCOMPATIBLE_CLASS_CHANGE_ERROR);
expectedRep.add(AnySubType.v(utility.INCOMPATIBLE_CLASS_CHANGE_ERROR));
assertTrue(ExceptionTestUtility.sameMembers(expectedRep, Collections.EMPTY_SET, unitAnalysis.mightThrow(s)));
assertEquals(utility.THROW_PLUS_INCOMPATIBLE_CLASS_CHANGE_PLUS_SUBTYPES_PLUS_SUPERTYPES, utility.catchableSubset(unitAnalysis.mightThrow(s)));
// Throw a local of unknown type.
local = Jimple.v().newLocal("local1", soot.UnknownType.v());
s.setOp(local);
assertTrue(ExceptionTestUtility.sameMembers(utility.ALL_THROWABLES_REP, Collections.EMPTY_SET, unitAnalysis.mightThrow(s)));
assertEquals(utility.ALL_TEST_THROWABLES, utility.catchableSubset(unitAnalysis.mightThrow(s)));
}
Aggregations