[Soot-list] Java-Jimple mapping using SourceLnPosTag

Josh Branchaud jbranchaud at gmail.com
Fri Mar 9 15:07:21 EST 2012


Hi Marcus,

I am sure someone can try to explain to you why the Jimple code looks as it
does. I am not going to try to do that.

My assumption from your question is that you aren't familiar with JVM
bytecode. Let me know if this assumption is incorrect. I think if you were
to learn a little about bytecode and how it is related to Java code, this
would not only give you a much stronger understanding of how Java works
under the hood, but I think it would also give you some insight on how
Jimple relates to Java source code. This isn't a quick fix. If you are
interested in getting a quick answer in a couple paragraphs, then this
isn't the way to go. However, if you looking for a more long-term, deeper
understanding of these concepts, then I think it would be well worth your
time to learn a little about the JVM and bytecode.

Here is a link to the JVM
specification<http://docs.oracle.com/javase/specs/jvms/se5.0/html/VMSpecTOC.doc.html>.
Perhaps others on the mailing list have suggestions for resources to check
out.

On Fri, Mar 9, 2012 at 12:24 PM, Marcus Mews <m.mews at tu-berlin.de> wrote:

>
> Hello everybody,
>
>    I am Marcus Mews (TU-Berlin) and about to use Soot in an academic
> prototype to perform semantic preserving refactorings. Therfor, I need
> to know certain details about Soot's mapping between Java Expressions
> and Jimple Units. For various reasons, Soot splits up Java Expressions
> like from
>
> void JavaFoo() {
> x++;
> }
>
> to
>
> void JimpleFoo() {
>     temp$1 = this.<some.Clazz: int x>;  //sline=134, eline=134, spos=1,
> epos=1
>     temp$2 = temp$1 + 1;                //sline=134, eline=134, spos=1,
> epos=1
>     this.<some.Clazz: int x> = temp$2;  //sline=134, eline=134, spos=1,
> epos=1
> }
>
> Another - slightly different - case is the following example: From
>
> void JavaBar() {
> x=x+1;
> }
>
> to
>
> void JimpleBar() {
>     temp$3 = this.<some.Clazz: int x>;    //sline=135, eline=135,
> spos=3, epos=3
>     temp$4 = temp$3 + 1;                  //sline=135, eline=135,
> spos=3, epos=3
>     this.<some.Clazz: int x> = temp$4;    //sline=135, eline=135,
> spos=1, epos=1
> }
>
>
>    In the first example above, the expression "x++" is substituted by
> three other expressions in the Jimple code, since there is no equivalent
> in the Jimple language, I assume. In the second example, the expression
> "x=x+1" is just split up into more trivial expressions.
>    I'd like to know where each Jimple unit comes from.
>
>    I considered using the SourceLnPosTag, but I'm not sure, whether
> this is the right thing to do; in the examples above, I also stated the
> SourceLnPosTags: In the "x++"-example, all the SourceLnPosTags point to
> the same Java code text snippet, which is as I expected (although I it
> seems odd that epos=1 instead of epos=3). But in the second example I
> don't understand the position numbers, since some Jimple units have
> equal SourceLnPosTags. Maybe the tags are incorrect or maybe I'm off the
> track here and there is a better way to retrieve each unit's Java origin?
>
>    Anyway, I appreciate any advice or links to manuals, etc.
> Thanks and regards,
>    Marcus
>
>
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>



-- 
Josh Branchaud
Graduate Research Assistant, University of Nebraska-Lincoln
jbranchaud at gmail.com - (402) 660-1656
Website: cse.unl.edu/~jbrancha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20120309/521ac5df/attachment.html 


More information about the Soot-list mailing list