[Soot-list] Changing reference of super class through out project

Marc Miltenberger Marc.Miltenberger at cased.de
Wed Aug 12 05:01:27 EDT 2015


Hi,
  something like this should work:
for (Unit u : jimpleBody.getUnits()) {
    if (u instanceof Stmt) {
       Stmt s = (Stmt) u;
       if (s.containsInvokeExpr()) {
          if (s.getInvokeExpr() instanceof JSpecialInvokeExpr) {
             JSpecialInvokeExpr jspecialInvokeExpr = 
(JSpecialInvokeExpr) s.getInvokeExpr();
             if 
(jspecialInvokeExpr.getMethod().getDeclaringClass().equals(oldParent))
                SootMethod newMethod = 
newParentClass.getMethod(jspecialInvokeExpr.getMethod().getSubSignature());
                jspecialInvokeExpr.setMethodRef(newMethod.makeRef());
          }
       }
    }
}

Marc



Am 12.08.2015 um 10:53 schrieb Tanzirul Azim:
> Hi,
>
> I have changed the super class declaration of some of the classes in the
> project. But the problem arises for the methods that were invoked using
> super. To be clear consider the following scenario.
>
> Class child extends class Parent. I changed the declaration to
> NewParent. So, NewParent is the super class of class Child. But all the
> super methods that are invoked in class Child still refer to the Parent
> class in the byte code, as in byte code the invoke statements are
> directly associated with containing classes. So, any method call say
> super.foo() inside child actually calls Parent: foo(), I want to replace
> those with NewParent: foo()
>
> How can I do that? I have created a body transformer. But still figuring
> out the solution.
> --
> Regards,
> Tanzirul Azim
>
>
>
> _______________________________________________
> Soot-list mailing list
> Soot-list at CS.McGill.CA
> https://mailman.CS.McGill.CA/mailman/listinfo/soot-list
>



More information about the Soot-list mailing list