[Soot-list] verification error on accessing fields

Paris Yiapanis yiapanip at cs.man.ac.uk
Thu Jun 24 04:18:47 EDT 2010


Hi,

I think the problem has something to do with casting.

For instance, I generate the following Jimple code:

public void m()
{
        myPackage.MyClass r0;
        java.lang.Object r1;
        int[] r2;
        myPackage.TempClass r3;

        r0 := @this: myPackage.MyClass;
        r1 = r0.<myPackage.MyClass: java.lang.Object objRef>;
        r3 = (myPackage.TempClass) r1;
        r2 = r3.<myPackage.TempClass: int[] a>;
        ....
        ....
        return;
  }

At the statement "r3 = (myPackage.TempClass) r1;", Jimple shows that it
casts 'r1'. However, if I check the bytecode produced from that,
it doesn't actually have a 'checkcast' code. So I guess that the casting
doesn't actually happen.
I was trying to use the JCastExpr but I am not sure how it exactly works.
I tried to create a JCastExpr(r1, myPackage.MyClass) but it complains that:
Box VB(null) cannot contain value: r0.<myPackage.MyClass: java.lang.Object
objRef>(class soot.jimple.internal.JInstanceFieldRef)

Any ideas? Any help appreciated.

Thanks

- Paris


On Wed, Jun 23, 2010 at 4:51 PM, Paris Yiapanis <yiapanip at cs.man.ac.uk>wrote:

> Hi Eric,
>
> First of all thank you very much for your quick response. It is highly
> appreciated.
>
> The package name is my mistake now while copying, but it is actually the
> same in my code.
>
> I have tried the '-validate' option as you suggested but it didn't show
> anything.
>
> The TempClass looks like:
>
> public class TempClass {
>     public int[] a = new int[10];
>     public int[] b = new int[10];
>
>     public TempClass(){
>            initializeArrayA();
>     }
>
>         public void m(){
>
>            for(int i= 0; i < a.length; i++){
>                b[i] = a[i];
>            }
>
>     }
> }
>
> In my code I am generating from scratch a class myClass that gets a hold of
> the 'this' reference of TempClass and accesses its fields.
>
> Now I had another issue that I do not know to what extend may be causing
> the problem (and I hope I don't confuse the things):
>
> Inside myClass class as you can see from my Jimple earlier, I am accessing
> an instance field 'objRef'.
> However, objRef field is not declared inside myClass. It is declared in
> another class called 'AbstractClass' which myClass extends.
> So, while producing jimple I couldn't say:
> myClass.getFieldByName('objRef'). It was complaining that 'myClass' doesn't
> have such a field.
> Thus I had to use the superclass to access that field:
> myClass.getSuperclass().getFieldByName('objRef').
>
> I didn't mention that in my jimple code above to keep things simpler, but
> the jimple statement is actually:
> r1 = r0.<myPackage.*AbstractClass*: java.lang.Object objRef>;
>
> rather than:
>
> r1 = r0.<myPackage.*MyClass*: java.lang.Object objRef>;
>
> In reality I should have been able to use MyClass.objRef, isn't it?
> I don't know if this contributes to my verification problem  later.
> I hope I didn't make things more confusing.
>
>
> Thank you in advance,
>
> Paris
>
> On Wed, Jun 23, 2010 at 4:14 PM, Eric Bodden <
> bodden at st.informatik.tu-darmstadt.de> wrote:
>
>> By the way: why are you using different package names?
>>
>> testLoops2.TempClass in the cast but myPackage.TempClass in the field
>> access.... may that be the mistake?
>>
>> Eric
>>
>> --
>> Dr. Eric Bodden
>> Software Technology Group, Technische Universität Darmstadt, Germany
>> Tel: +49 6151 16-5478    Fax: +49 6151 16-5410
>> Mailing Address: S2|02 A209, Hochschulstraße 10, 64289 Darmstadt
>>
>>
>>
>> On 23 June 2010 17:13, Eric Bodden <bodden at st.informatik.tu-darmstadt.de>
>> wrote:
>> >> Does anyone know any way around this problem, as I do not want to
>> disable
>> >> verification?
>> >
>> > Hmm, I don't see anything wrong. It may help to see the code of
>> > TempClass... You may try the -validate switch to Soot. That will do
>> > some validation on your Jimple code.
>> >
>> > Eric
>> >
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20100624/82d13f30/attachment.html 


More information about the Soot-list mailing list