[Soot-list] Body Transformer : Problem Add New Method in Chain

Eric Bodden eric.bodden at mail.mcgill.ca
Sat Jan 24 10:24:02 EST 2009


Jimple is a three-address code. This means that you cannot have any
complex expressions like a new-array statement as an operand or
parameter. In other words you first have to (1) create a new local
variable, then (2) assign the new-array expression to that variable,
and (3) use that variable when you create the method call.

Also there's a typo in your code. It's java.lang, not Java.lang.

In general it may help you to (a) look at the Jimple grammar (it's
part of the source distribution of Soot) to see what is valid Jimple
and what isn't, and (b) to transform some Java source files to Jimple
using the "-f J" option to Soot. The latter should show you what code
for such constructs ought to look like.

Eric

2009/1/24 Amir Mehrabi <mehrabi at comp.iust.ac.ir>:
>
> Hi
>
> For construct an invovcation to CHECK method I write these statements:
>
> Signletons s=new Singletons();
> NewArrayExpr myExpr=enw
> JNewArrayExpr(s.soot.RefType().v("Java.lang.Object"),IntConstant.v(5));
> List params=new ArrayList();
> params.add(StringConstant.v("aaaaa"));
> params.add(StringConstant.v("bbbbb"));
> params.add(myExpr);
>
> InvokeExpr incExpr=Jimple.v().newStaticInvokeExpr(check.makeRef(),params);
> Stmt incStmt=Jimple.v().newInvokeStmt(incExpr);
> units.insertBefor(incStmt,oldStmt);
>
>
> this is part of my Transform Body but I got a ERROR:
>
> Box VB(null) cannot contain value : newarray(java.lang.Object)[5](class
> soot.jimple.internal.JNewArrayExpr)
> at soot.AbstractValueBox.setValue(AbastractValueBox.java:42)
>
>
> I don't know why this error occure.
> please help me....
>
> thank you.
>
> -----Original Message-----
> From: "Amir Mehrabi" <mehrabi at comp.iust.ac.ir>
> To: "Eric Bodden" <eric.bodden at mail.mcgill.ca>
> Cc: soot-list at sable.mcgill.ca
> Date: Sat, 24 Jan 2009 12:43:05 +0330
> Subject: Re: [Soot-list] Body Transformer : Problem Add New Method in Chain
>
> Hi could you please show me by example how can I invoke a method in Jimple
> Format such as:
>          void check(String a,String b,Object[] c);
>
> thankl you
>
>
> -----Original Message-----
> From: Eric Bodden <eric.bodden at mail.mcgill.ca>
> To: Amir Mehrabi <mehrabi at comp.iust.ac.ir>
> Cc: soot-list at sable.mcgill.ca
> Date: Wed, 21 Jan 2009 09:30:10 -0500
> Subject: Re: [Soot-list] Body Transformer : Problem Add New Method in Chain
>
> You have to construct a new array using
> soot.jimple.Jimple.newNewArrayExpr(Type, Value).
>
> Eric
>
> 2009/1/21 Amir Mehrabi <mehrabi at comp.iust.ac.ir>:
>> Hi
>> I want to by BodyTransformer add one method to the existing method's body
>> my method is:
>>
>> void check(String name,String arg1,Object[] objs);
>>
>> in jimple there is statement for adding some statement in unit like :
>>
>>   newStaticInvokeExpr ( SootMethodRef  method, List args)
>>   newStaticInvokeExpr( SootMethodRef method, Value arg)
>>   newStaticInvokeExpr ( SootMethodRef  method, Value  arg1, Value  arg2)
>> for sending String Value I use
>>
>>               StringConstant.v("some text");
>>
>> but I don't know how to send array of Object for passing Object[]
>> Can any one help me please?
>>
>> Thank you
>> Amir Mehrabi
>> MSc Student of Iran University Of Science and Technology
>>
>> _______________________________________________
>> Soot-list mailing list
>> Soot-list at sable.mcgill.ca
>> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>>
>>
>
>
>
> --
> Eric Bodden
> Sable Research Group, McGill University
> Montréal, Québec, Canada
>
>
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>
>



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


More information about the Soot-list mailing list