protected void transform(ValueBox invocationBox, VirtualInvokeExpr invocation) { Value virtualInstanceReference = invocation.getBase(); // AugmentedString.decorate(Object) SootMethodRef newMethodRef = soot.Scene.v() .getSootClass(replacementClass.getName()) .getMethod("decorate", Lists.newArrayList(Scene.v().getObjectType())) .makeRef(); InvokeExpr newInvocation = new JStaticInvokeExpr(newMethodRef, Lists.newArrayList(virtualInstanceReference)); invocationBox.setValue(newInvocation); }
protected void transform(ValueBox invocationBox, StaticInvokeExpr invocation) { // Integer.toString(int) -> AugmentedString.decorate(int) SootMethodRef newMethodRef = soot.Scene.v() .getSootClass(replacementClass.getName()) .getMethod("decorate", invocation.getArgs().stream().map(Value::getType).collect(Collectors.toList())) .makeRef(); InvokeExpr newInvocation = new JStaticInvokeExpr(newMethodRef, invocation.getArgs()); invocationBox.setValue(newInvocation); }
protected void transform(ValueBox invocationBox, InterfaceInvokeExpr invocation) { // Interface.toString(int) -> RecordSet.decorate(int) SootMethodRef newMethodRef = soot.Scene.v() .getSootClass(replacementClass.getName()) .getMethod("decorate", getArgumentTypes(invocation)) .makeRef(); InvokeExpr newInvocation = new JStaticInvokeExpr(newMethodRef, getArguments(invocation)); invocationBox.setValue(newInvocation); }
@Test public final void testExtractLn() { Stmt statement1 = new JInvokeStmt(new JStaticInvokeExpr(sootMethod1C1.makeRef(), new ArrayList<Object>())); Tag tag1 = new SourceLnPosTag(8, 8, 3, 4); statement1.addTag(tag1); Stmt statement2 = new JReturnVoidStmt(); Tag tag2 = new SourceLnPosTag(532, 532, 3, 4); statement2.addTag(tag2); Stmt statement3 = new JReturnVoidStmt(); assertTrue("Correct line number", extractLineNumber(statement1) == 8); assertTrue("Correct line number", extractLineNumber(statement2) == 532); assertTrue("No line number present", extractLineNumber(statement3) == 0); }
public void visit(InvokeExpr e) { if (e instanceof JStaticInvokeExpr) { JStaticInvokeExpr ex = (JStaticInvokeExpr) e; add(e, ex.getMethod()); } }