[Soot-list] How could I get the assignment statement of a "static final" field with soot?

周书林 zhoushulin1992 at gmail.com
Sat Apr 14 05:01:43 EDT 2018


Hi,

I am novice in soot, and I want to analyse some Java projects. But there is
some puzzle during the jimple analysis.

In my analysis, I want to get the definition of the class fields, including
the field name, attributes, and value. But there is something wrong.

For the following class bat, I define a "final static" field "TEST_FIELD",
and a "static" field "TEST_FIELD2". But in the jimple code, the "final
static TEST_FIELD" is simplified as "100". I tried to find it in the
"<clinit>" method. However, when I got the units in "<clinit>" method, I
couldn't find the assignment for the "final static TEST_FIELD". More weird,
if I delete the definition of "public static int TEST_FIELD2 = 100", I
cannot even get the "<clinit>" method by API "SootClass.getMethodByName()".

*public class bat{*
* public static final int TEST_FIELD = 100;*
* public static int TEST_FIELD2 = 100;*

* public int method1(int a){*
* return TEST_FIELD+a;*
* }*

* public static void main(String[] args){*
* bat b = new bat();*
* int a = 0;*
* int r1 = b.method1(b.TEST_FIELD);*
* int r2 = b.method1(b.TEST_FIELD2);*
* System.out.println(r1);*
* System.out.println(r2);*
* }*
*}*

So, my question is : how could I get access to the definition of this
"static final" field.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20180414/a3d7c6c3/attachment.html>


More information about the Soot-list mailing list