[Soot-list] how to get the initial value of sootField

Tobias Gutzmann tobias.gutzmann at lnu.se
Wed May 19 17:44:54 EDT 2010


Hello,

I double-checked real quick. Might get a little off-topic (not regarding soot), please excuse this.
It seems that (at least in the rt.jar) only final fields have "ConstantValueInfo" tags, e.g., java.lang.Math.E
Strangely enough, non-static "private final" fields may also have them (no, the compiler does *not* set the "static" flag for them) - in contrast to the Java Class File specification, see my previous post. Example: java.io.Writer.bufferSize. I obtained this by reading in the rt.jar versions 1.6.0_18 and 1.6.0_20 - maybe it should be filed as a bug with sun/oracle?
Note, again, I am not sure about the behavior of soot in this matter, I performed my quick tests with the ASM framework.

Regards,
Tobias
________________________________________
From: soot-list-bounces at sable.mcgill.ca [soot-list-bounces at sable.mcgill.ca] On Behalf Of Stefan Willenbrock [willenbr at rhrk.uni-kl.de]
Sent: Wednesday, May 19, 2010 11:11 PM
To: soot-list at sable.mcgill.ca
Subject: Re: [Soot-list] how to get the initial value of sootField

Am 19.05.2010 20:35, schrieb dingsun:
> Class A{
> public int x=999;
>
> public void f1(){
>
> ......
> }
>
>
> }

Java doesn't store initial field assignments in that way at the byte
code level, so jimple also doesn't do it, since it has nearly the same
level of abstraction.

Rather all initial (instance) assignments are collected and put into a
method called "<init>". This is the same as the constructor and then
assigns these values upon construction of the object to the fields.

The same procedure exists for static fields. Here the assignments are
stored within the "<clinit>" method, which is called upon class load.

What you could do is check the <init> method for constant assignments to
field x.

Regards, Stefan
_______________________________________________
Soot-list mailing list
Soot-list at sable.mcgill.ca
http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list


More information about the Soot-list mailing list