<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi,<div class=""><br class=""></div><div class="">the optimization of static final fields is already done by the compiler. If you use javap to decompile the byte code  you will find that the value is already inlined. The byte code also tells that there is a Constant attribute assigned to the field. Perhaps you can use the Tag-API of Soot to fetch the value.</div><div class=""><br class=""></div><div class="">Cheers, Bernhard</div><div><br class=""><blockquote type="cite" class=""><div class="">Am 14.04.2018 um 11:01 schrieb 周书林 <<a href="mailto:zhoushulin1992@gmail.com" class="">zhoushulin1992@gmail.com</a>>:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi,<div class=""><br class=""></div><div class="">I am novice in soot, and I want to analyse some Java projects. But there is some puzzle during the jimple analysis.</div><div class=""><br class=""></div><div class="">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.</div><div class=""><br class=""></div><div class="">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<span class="sew9h0lvea05cqo"></span><span class="sewu3f1zns02zqe"></span>". More weird, if I delete the definition of "public static int TEST_FIELD2 = 100", I cannot even get the "<clinit>" method by API "<span style="color:rgb(78,144,114);font-family:Monaco;font-size:11px" class="">SootClass.getMethodByName()<span class="sew9h0lvea05cqo"></span><span class="sewu3f1zns02zqe"></span></span>".<br class=""></div><div class=""><span class="sewu3f1zns02zqe"></span></div><div class=""><br class=""></div><div class=""><div class=""><i class=""><font face="tahoma, sans-serif" class="">public class bat{</font></i></div><div class=""><i class=""><font face="tahoma, sans-serif" class=""><span class="Apple-tab-span" style="white-space:pre">   </span>public static final int TEST_FIELD = 100;</font></i></div><div class=""><i class=""><font face="tahoma, sans-serif" class=""><span class="Apple-tab-span" style="white-space:pre">   </span>public static int TEST_FIELD2 = 100;</font></i></div><div class=""><i class=""><font face="tahoma, sans-serif" class=""><br class=""></font></i></div><div class=""><i class=""><font face="tahoma, sans-serif" class=""><span class="Apple-tab-span" style="white-space:pre">   </span>public int method1(int a){</font></i></div><div class=""><i class=""><font face="tahoma, sans-serif" class=""><span class="Apple-tab-span" style="white-space:pre">          </span>return TEST_FIELD+a;</font></i></div><div class=""><i class=""><font face="tahoma, sans-serif" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>}</font></i></div><div class=""><i class=""><font face="tahoma, sans-serif" class=""><br class=""></font></i></div><div class=""><i class=""><font face="tahoma, sans-serif" class=""><span class="Apple-tab-span" style="white-space:pre">      </span>public static void main(String[] args){</font></i></div><div class=""><i class=""><font face="tahoma, sans-serif" class=""><span class="Apple-tab-span" style="white-space:pre">             </span>bat b = new bat();</font></i></div><div class=""><i class=""><font face="tahoma, sans-serif" class=""><span class="Apple-tab-span" style="white-space:pre">          </span>int a = 0;</font></i></div><div class=""><i class=""><font face="tahoma, sans-serif" class=""><span class="Apple-tab-span" style="white-space:pre">          </span>int r1 = b.method1(b.TEST_FIELD);</font></i></div><div class=""><i class=""><font face="tahoma, sans-serif" class=""><span class="Apple-tab-span" style="white-space:pre">           </span>int r2 = b.method1(b.TEST_FIELD2);</font></i></div><div class=""><i class=""><font face="tahoma, sans-serif" class=""><span class="Apple-tab-span" style="white-space:pre">          </span>System.out.println(r1);</font></i></div><div class=""><i class=""><font face="tahoma, sans-serif" class=""><span class="Apple-tab-span" style="white-space:pre">             </span>System.out.println(r2);</font></i></div><div class=""><i class=""><font face="tahoma, sans-serif" class=""><span class="Apple-tab-span" style="white-space:pre">     </span>}</font></i></div><div class=""><i class=""><font face="tahoma, sans-serif" class="">}<span class="sew9h0lvea05cqo"></span><span class="sewu3f1zns02zqe"></span></font></i></div></div><div class=""><i class=""><font face="tahoma, sans-serif" class=""><br class=""></font></i></div><div class=""><font face="arial, helvetica, sans-serif" class="">So, my question is : how could I get access to the definition of this "static final" field.</font></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div></div>
_______________________________________________<br class="">Soot-list mailing list<br class=""><a href="mailto:Soot-list@CS.McGill.CA" class="">Soot-list@CS.McGill.CA</a><br class="">https://mailman.CS.McGill.CA/mailman/listinfo/soot-list<br class=""></div></blockquote></div><br class=""></body></html>