[Soot-list] How to propagate constant defined in class fields to class methods ?

Steven Arzt Steven.Arzt at cased.de
Mon Feb 9 07:36:26 EST 2015


Hi Xinxin,

 

The problem is that, without the “final” keyword, this is not a constant. There is no guarantee that the value is not overwritten anywhere in the code. What you are interested in is thus not the “constant” value, but rather the value the variable was initialized with – disregarding that the variable can hold a totally different value at later points in the program execution.

 

To get such a constant initialization value, I would fetch the <clinit> method and check for assignments to the respective field.

 

Best regards,

  Steven

 

Von: soot-list-bounces at CS.McGill.CA [mailto:soot-list-bounces at CS.McGill.CA] Im Auftrag von Xinxin Jin
Gesendet: Samstag, 7. Februar 2015 23:08
An: Dacong Yan
Cc: Soot list
Betreff: Re: [Soot-list] How to propagate constant defined in class fields to class methods ?

 

Thanks for the reply ! Yes, "final int DEFAULT_TIMEOUT " works, but go back to my problem, is there any way to get the value without "final" keyword ? Thank you !

 

On Sat, Feb 7, 2015 at 12:30 PM, Dacong Yan <tonywinslow1986 at gmail.com> wrote:

Although named in all capitals, DEFAULT_TIMEOUT is not a constant.
Maybe you can change it to
  private final int DEFAULT_TIMEOUT = 30000;
and see what happens.


On Sat, Feb 7, 2015 at 10:49 AM, Xinxin Jin <xinxinjin89 at gmail.com> wrote:
> Hello,
>
> I have a question about how constants propagate from class fields to class
> methods. I have a simple testing code:
>
> public class MyActivity extends ActionBarActivity {
>     private int DEFAULT_TIMEOUT = 30000;
>
>     @Override
>   protected void onCreate(Bundle savedInstanceState) {
> super.onCreate(savedInstanceState);
> new FetchItemsTask().execute();
>   }
>   private class FetchItemsTask extends AsyncTask<Void,Void,String>{
> @Override
> protected String doInBackground(Void... arg0) {
>             int timeoutConnection = DEFAULT_TIMEOUT;
>   HttpParams httpParameters = new BasicHttpParams();
>   HttpConnectionParams.setConnectionTimeout(httpParameters,
> timeoutConnection);
>         }
> }
>
> Basically I want to get the value of timeoutConnection called by
> setConnectionTimeout. I used both ConstantPropagatorAndFolder() defined in
> soot and InterproceduralConstantValuePropagator() defined in Soot-infoflow,
> and expect DEFAULT_TIMEOUT should propagate to the parameter of
> setConnnectionTimeout. However, I cannot get the integer constant from
> setConnectionTimeout.
>
> I guess if neither  ConstantPropagatorAndFolder() nor
> InterproceduralConstantValuePropagator() propagate the class fields to class
> methods ?  Then what is the correct way to do this ?
> Please help me out !
>
> Thank you for your help in advance !
>
>
> --
> Xinxin
>

> _______________________________________________
> Soot-list mailing list
> Soot-list at CS.McGill.CA
> https://mailman.CS.McGill.CA/mailman/listinfo/soot-list
>





 

-- 

Xinxin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20150209/067d6941/attachment.html 


More information about the Soot-list mailing list