public void outAThrowStatement(AThrowStatement node) { Value op = (Value) mProductions.removeLast(); Unit u = Jimple.v().newThrowStmt(op); mProductions.addLast(u); }
public soot.jimple.ThrowStmt newThrowStmt(Value op, ASTNode location) { soot.jimple.ThrowStmt stmt = Jimple.v().newThrowStmt(op); soot.tagkit.Tag tag = getTag(op); if(tag != null) stmt.getOpBox().addTag(tag); return stmt; }
@Override public void jimplify(DexBody body) { Instruction11x throwInstruction = (Instruction11x) instruction; ThrowStmt throwStmt = Jimple.v().newThrowStmt(body.getRegisterLocal(throwInstruction.getRegisterA())); setUnit(throwStmt); addTags(throwStmt); body.add(throwStmt); if (IDalvikTyper.ENABLE_DVKTYPER) { DalvikTyper.v().setType(throwStmt.getOpBox(), RefType.v("java.lang.Throwable"), true); } } }
/** * Insert a runtime exception before unit u of body b. Useful to analyze broken code (which make reference to inexisting * class for instance) exceptionType: e.g., "java.lang.RuntimeException" */ public static void addExceptionAfterUnit(Body b, String exceptionType, Unit u, String m) { LocalCreation lc = new LocalCreation(b.getLocals()); Local l = lc.newLocal(RefType.v(exceptionType)); List<Unit> newUnits = new ArrayList<Unit>(); Unit u1 = Jimple.v().newAssignStmt(l, Jimple.v().newNewExpr(RefType.v(exceptionType))); Unit u2 = Jimple.v() .newInvokeStmt(Jimple.v().newSpecialInvokeExpr(l, Scene.v().makeMethodRef(Scene.v().getSootClass(exceptionType), "<init>", Collections.singletonList((Type) RefType.v("java.lang.String")), VoidType.v(), false), StringConstant.v(m))); Unit u3 = Jimple.v().newThrowStmt(l); newUnits.add(u1); newUnits.add(u2); newUnits.add(u3); b.getUnits().insertBefore(newUnits, u); }
/** * Throw Stmt Creation */ private void createThrow(polyglot.ast.Throw throwStmt) { soot.Value toThrow = base().createAggressiveExpr(throwStmt.expr(), false, false); soot.jimple.ThrowStmt throwSt = soot.jimple.Jimple.v().newThrowStmt(toThrow); body.getUnits().add(throwSt); Util.addLnPosTags(throwSt, throwStmt.position()); Util.addLnPosTags(throwSt.getOpBox(), throwStmt.expr().position()); }
static Stmt addThrowAfter(JimpleBody b, Stmt target) { Chain<Unit> units = b.getUnits(); Collection<Local> locals = b.getLocals(); int i = 0; // Bah! boolean canAddI = false; do { canAddI = true; Iterator<Local> localIt = locals.iterator(); while (localIt.hasNext()) { Local l = (Local) localIt.next(); if (l.getName().equals("__throwee" + i)) { canAddI = false; } } if (!canAddI) { i++; } } while (!canAddI); Local l = Jimple.v().newLocal("__throwee" + i, RefType.v("java.lang.NullPointerException")); b.getLocals().add(l); Stmt newStmt = Jimple.v().newAssignStmt(l, Jimple.v().newNewExpr(RefType.v("java.lang.NullPointerException"))); Stmt invStmt = Jimple.v().newInvokeStmt(Jimple.v().newSpecialInvokeExpr(l, Scene.v().getMethod("<java.lang.NullPointerException: void <init>()>").makeRef())); Stmt throwStmt = Jimple.v().newThrowStmt(l); units.insertAfter(newStmt, target); units.insertAfter(invStmt, newStmt); units.insertAfter(throwStmt, invStmt); return newStmt; }
Unit newUnit = Jimple.v().newThrowStmt(ttt);
body.getUnits().insertAfter(printStackTraceStmt, initStmt); } else if (options.guards().equals("throw")) { body.getUnits().insertAfter(Jimple.v().newThrowStmt(exceptionLocal), initStmt); } else { throw new RuntimeException("Invalid value for phase option (guarding): " + options.guards());
/** * Creates a new statement that throws a NullPointerException * * @param body * The body in which to create the statement * @param oldStmt * The old faulty statement that shall be replaced with the exception * @param lc * The object for creating new locals */ private void createThrowStmt(Body body, Unit oldStmt, LocalCreation lc) { RefType tp = RefType.v("java.lang.NullPointerException"); Local lcEx = lc.newLocal(tp); SootMethodRef constructorRef = Scene.v().makeConstructorRef(tp.getSootClass(), Collections.singletonList((Type) RefType.v("java.lang.String"))); // Create the exception instance Stmt newExStmt = Jimple.v().newAssignStmt(lcEx, Jimple.v().newNewExpr(tp)); body.getUnits().insertBefore(newExStmt, oldStmt); Stmt invConsStmt = Jimple.v().newInvokeStmt(Jimple.v().newSpecialInvokeExpr(lcEx, constructorRef, Collections.singletonList(StringConstant.v("Invalid array reference replaced by Soot")))); body.getUnits().insertBefore(invConsStmt, oldStmt); // Throw the exception body.getUnits().swapWith(oldStmt, Jimple.v().newThrowStmt(lcEx)); } }
/** * Creates a new statement that throws a NullPointerException * * @param body * The body in which to create the statement * @param oldStmt * The old faulty statement that shall be replaced with the exception * @param lc * The object for creating new locals */ private void createThrowStmt(Body body, Unit oldStmt, LocalCreation lc) { RefType tp = RefType.v("java.lang.NullPointerException"); Local lcEx = lc.newLocal(tp); SootMethodRef constructorRef = Scene.v().makeConstructorRef(tp.getSootClass(), Collections.singletonList((Type) RefType.v("java.lang.String"))); // Create the exception instance Stmt newExStmt = Jimple.v().newAssignStmt(lcEx, Jimple.v().newNewExpr(tp)); body.getUnits().insertBefore(newExStmt, oldStmt); Stmt invConsStmt = Jimple.v().newInvokeStmt(Jimple.v().newSpecialInvokeExpr(lcEx, constructorRef, Collections.singletonList(StringConstant.v("Null throw statement replaced by Soot")))); body.getUnits().insertBefore(invConsStmt, oldStmt); // Throw the exception body.getUnits().swapWith(oldStmt, Jimple.v().newThrowStmt(lcEx)); }
soot.jimple.Stmt throwStmt = soot.jimple.Jimple.v().newThrowStmt(local); body.getUnits().add(throwStmt);
l.add(handlerStmt); l.add((Stmt) exitMon.clone()); l.add(Jimple.v().newThrowStmt(eRef)); units.insertAfter(l, newGoto);
units.add(Jimple.v().newThrowStmt(caughtExceptionLocal));
if (!units.containsKey(insn)) { opr = popImmediate(); ThrowStmt ts = Jimple.v().newThrowStmt(opr.stackOrValue()); opr.addBox(ts.getOpBox()); frame.in(opr);
soot.jimple.ThrowStmt throwStmt = soot.jimple.Jimple.v().newThrowStmt(failureLocal); body.getUnits().add(throwStmt);
soot.jimple.Stmt throwStmt = soot.jimple.Jimple.v().newThrowStmt(catchAllAssignLocal); throwStmt.addTag(new soot.tagkit.ThrowCreatedByCompilerTag()); body.getUnits().add(throwStmt);
soot.jimple.Stmt throwStmt = soot.jimple.Jimple.v().newThrowStmt(throwLocal); throwStmt.addTag(new soot.tagkit.ThrowCreatedByCompilerTag()); classBody.getUnits().add(throwStmt);
soot.jimple.Stmt throwStmt = soot.jimple.Jimple.v().newThrowStmt(throwLocal); throwStmt.addTag(new soot.tagkit.ThrowCreatedByCompilerTag()); classBody.getUnits().add(throwStmt);
body.getUnits().insertAfter(Jimple.v().newThrowStmt(exceptionLocal), initStmt);
units.add(Jimple.v().newThrowStmt(l_r4));