[Soot-list] Some Problem use Jimple to create class from scrap

Eric Bodden eric.bodden at mail.mcgill.ca
Mon Dec 15 08:30:28 EST 2008


> Problem 2: when I create new method, whether I must add the r0 := @this: B;?
> if I don't uset this.xx() in my new method?

You need a pointer to a local variable that holds the value of "this".
That means that there must be an identity statement in your method.
Either you put it there yourself (if there is none yet) or you reuse
the one that is there already (if any).

> Problem 3: when I modify a exited method, I want to use "this" variable in
> method, I find I can create a new newIdentityStmt(), but I can't add it to
> units chain, even I put this line in the head of the chain. Because there is
> already a newIdentityStmt. So I tmpRef1 = body.getLocals().getFirst(); to
> get the "this" varable. I wonder is it the right way to get "this" variable?
> That line will always exit and be at the head of unit chain?

An identity statement for "this" should always be the first statement
in an instance method, if it is present at all.

> Problem 4: when I want to get SootMethod, and the method has no arguments. I
> use A.getMethod("getName", new ArrayList(0), VoidType.v()), it report error
> and say no method.
Yes, because the return type of your getName() method is String, not
void. Use RefType.v("java.lang.String") instead of VoidType.v().

> Problem 5: if I use this.getClass().toString(), it will generate stack
> variables in Jimple. Could please tell me how to declare a stack variable?

You create a new Local and then you call body.getLocals().add(local).

Eric

-- 
Eric Bodden
Sable Research Group, McGill University
Montréal, Québec, Canada


More information about the Soot-list mailing list