[Soot-list] Generating invalid code

feiya200 at cs.uregina.ca feiya200 at cs.uregina.ca
Tue Jan 22 20:04:33 EST 2008


Hi,

Well I'm actually replying a 2 years old thread, because I encountered  
the same problem and luckily I worked it out.

http://www.sable.mcgill.ca/pipermail/soot-list/2006-February/000516.html

Problem description:
After injecting some code in the begining of a method, like

> oldUnits.insertBefore(units, oldUnits.getFirst());

Soot generated invalid code that can not execute:

> Exception in thread "main" java.lang.VerifyError: (class: test/A,  
> method: getName signature: ()Ljava/lang/String;) Incompatible type  
> for getting or setting field
>     at uk.ac.ic.doc.cuXca.prototypes.soot.SootTest1.main(SootTest1.java:55)

Reason:
After spent some time debuging, I realized for non-static methods, the  
first unit of a method body is always a "r0 = @this", so injecting  
codes before that will change the "this" reference to locals other  
than "r0".

Solution:
Use "oldUnits.insertAfter(units, oldUnits.getFirst());" in a  
non-static method instead.


Probably you guys all have known about this but I just post it here as  
a reminder. Thanks.

Alvin

---------------------------------------------------
This mail was sent via the Secure Web Server at the
University of Regina Department of Computer Science
         https://www.cs.uregina.ca/WebMail/





More information about the Soot-list mailing list