WALA icon indicating copy to clipboard operation
WALA copied to clipboard

Initial values of static fields in DexIField

Open sifislag opened this issue 6 years ago • 2 comments

Hello, In Java static fields with initial values are initialized in <clinit>. However in dex bytecode static fields are not initialized in <clinit> and the initial values are stored in an array (For more information check static_values_off in https://source.android.com/devices/tech/dalvik/dex-format).

Dexlib2 has a way to access the initial value of a static field: org.jf.dexlib2.iface.Field :: getInitialValue(). However I do not see this feature integrated anywhere in WALA. Is it possible to do this somehow and if not could you support it?

Thanks in advance, Sifis.

sifislag avatar Jun 04 '18 11:06 sifislag

It sounds like what we need to is use the getInitialValue API for each static field in the class, and add initialization of each field to the static method. If that is what we need to do, then it is highly possible and I will do it soon. If that is not what we need to do, then perhaps you could clarify.

juliandolby avatar Jun 04 '18 16:06 juliandolby

Sorry my initial message missed the word "<clinit>" in two places due to formatting. What you suggest would solve this problem. Thank you.

sifislag avatar Jun 05 '18 09:06 sifislag