[Soot-list] variable name conflict

Sergio Ferrero sferrero at ensoftcorp.com
Thu Jul 4 13:17:43 EDT 2013


I found that Soot does not properly support the case in which the same
variable name is declared in different java blocks.

I created an example in which a variable named "x" is used in different
blocks:

package soot.test;

public class Locals {
public void testDeclarations() {
 // Block 1
 {
String x = "hello";
 }

 // Block 2
{
 char x = 'a';
}

// Block 3
 for (int x = 0; x < 10; x++) {
 }
}
}


I generated Jimple code using the Soot's eclipse plugin by right clicking
on the file and selecting
"Soot->Process Source File->Create Jimple"

The generated Jimple code redefines the variable with the same name three
times in the method body. If I check all use and def boxes for the local
variables, only the last variable definition is the one taken into account,
that is "int x". The other definitions of "x" are never use in any value
box.
Below is the Jimple code for the testDeclarations() method.

    public void testDeclarations()
    {
        soot.test.Locals this;
        java.lang.String x;
        char x;
        int x, temp$0, temp$1;

        this := @this: soot.test.Locals;
        x = "hello";
        x = 97;
        x = 0;

     label0:
        nop;
        if x < 10 goto label1;

        goto label2;

     label1:
        nop;
        nop;
        temp$0 = x;
        temp$1 = temp$0 + 1;
        x = temp$1;
        goto label0;

     label2:
        nop;
        return;
    }


Is this a bug in Soot or is there any Soot option I need to change to
properly support this use case?

Thanks
Sergio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20130704/6d77d212/attachment.html 


More information about the Soot-list mailing list