[Soot-list] Bad use of primitive type when performing transformations needed

Bernhard Berger berber at tzi.de
Sat Jun 8 11:32:21 EDT 2013


Hi Zeinab,

you have to do the auto boxing magic that is done by the compiler. You have to create a new instance of Integer and call the constructor with your int constant. The instance can be added to the list.

Regards,
Bernhard
Am 08.06.2013 um 17:01 schrieb Zeinab Lashkaripour <lashkaripour at yahoo.com>:

> Hi every one,
> 
> I need to perform the following transformation:
> Add a constant value to an ArrayList. If the list is named info and I want to add a constant 14, then I need to add the following to the code:
>     info.add(14)
> 
> I used a newVirtualInvokeExpr for this and a IntConstant.v(14) for the parameter and I got the exception [1]. Because int is a primitive and not an object I thought that the exception might be related to the fact that I used a IntConstant as parameter therefore, I added a new Integer local and assigned it to IntConstant.v(14) then used the local as the parameter of the method and got the exception in [2]. I know that the second way I tried is somehow the same as the first one but, I don't know another way to use so that the exception will not appear.
> 
> Could any one help me in this issue?
> 
> Regards,
> Zeinab
> 
> [1]
> Exception in thread "main" java.lang.RuntimeException: Warning: Bad use of primitive type in argument 0 of call at virtualinvoke info.<java.util.ArrayList: boolean add(java.lang.Object)>(14) in <.....> in <...................>
>     at soot.Body.checkCopy(Body.java:645)
>     at soot.Body.checkTypes(Body.java:632)
>     at soot.Body.validate(Body.java:236)
>     at soot.jimple.JimpleBody.validate(JimpleBody.java:66)
>     at soot.PackManager.runBodyPacks(PackManager.java:777)
>     at soot.PackManager.runBodyPacks(PackManager.java:463)
>     at soot.PackManager.runBodyPacks(PackManager.java:380)
>     at soot.PackManager.runPacks(PackManager.java:357)
>     at soot.Main.run(Main.java:198)
>     at soot.Main.main(Main.java:141)
>     at MyMain.main(MyMain.java:77)
> 
> [2]
> Exception in thread "main" java.lang.RuntimeException: Warning: Bad use of primitive type at k = 14 in <.....> in <...................>
>     at soot.Body.checkCopy(Body.java:645)
>     at soot.Body.checkTypes(Body.java:610)
>     at soot.Body.validate(Body.java:236)
>     at soot.jimple.JimpleBody.validate(JimpleBody.java:66)
>     at soot.PackManager.runBodyPacks(PackManager.java:777)
>     at soot.PackManager.runBodyPacks(PackManager.java:463)
>     at soot.PackManager.runBodyPacks(PackManager.java:380)
>     at soot.PackManager.runPacks(PackManager.java:357)
>     at soot.Main.run(Main.java:198)
>     at soot.Main.main(Main.java:141)
>     at MyMain.main(MyMain.java:77)
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20130608/47e86fbb/attachment.html 


More information about the Soot-list mailing list