[Soot-list] ThreadLocal class
Eric Bodden
bodden at st.informatik.tu-darmstadt.de
Wed Aug 18 02:58:55 EDT 2010
You can iterate through all useBoxes or defBoxes of a method body and
then look into these boxes. If there's an appropriate FieldRef in
there, replace it with whatever you like.
Eric
--
Dr. Eric Bodden
Software Technology Group, Technische Universität Darmstadt, Germany
Tel: +49 6151 16-5478 Fax: +49 6151 16-5410
Mailing Address: S2|02 A209, Hochschulstraße 10, 64289 Darmstadt
On 16 August 2010 18:12, yi zhang <cathy.zhyi at gmail.com> wrote:
> Hi, Eric:
> Could you give me a clue on how to do the fourth step: 4.) replace
> all references to the field ? Is there any API in soot which can make me
> find all the reference to a field of a class easily? This may include both a
> direct FieldRef to this field or in form of Local.thisfield?
>
>
> On Mon, Jul 26, 2010 at 3:52 AM, Eric Bodden
> <bodden at st.informatik.tu-darmstadt.de> wrote:
>>
>> Hello.
>>
>> Since ThreadLocal is just a java class like any other class, Soot
>> certainly supports it. I am assuming that you are doing something
>> wrong in the code generation.
>>
>> My estimation would be that for every field you need to...
>>
>> 1.) create a new sub-class of ThreadLocal
>> 2.) construct an initialValue method in that subclass
>> 3.) replace the field and assign to it at the right point in time
>> 4.) replace all references to the field
>>
>> Eric
>>
>> --
>> Dr. Eric Bodden
>> Software Technology Group, Technische Universität Darmstadt, Germany
>> Tel: +49 6151 16-5478 Fax: +49 6151 16-5410
>> Mailing Address: S2|02 A209, Hochschulstraße 10, 64289 Darmstadt
>>
>>
>>
>> On 24 July 2010 17:53, yi zhang <cathy.zhyi at gmail.com> wrote:
>> > Hi everyone:
>> > I am using soot to optimize this code. However, soot seems have
>> > problem dealing with the ThreadLocal field. Whenever I include the
>> > ThreadLocal HelloWorld I got error: Exception in thread "main"
>> > java.lang.NoClassDefFoundError: HelloWorld$1 when running the .class
>> > generated by soot. When I delete the threadlocal helloworld everything
>> > works
>> > fine. Does soot really support the threadlocal class?
>> >
>> > What I want to do currently is: Give a java class, change all the
>> > fields which are static non-volatile to ThreadLocal. I am thinking doing
>> > this after the soot has loaded all the classes and change them to
>> > sootclass
>> > before any jimple transfromation happans. Could anyone give me some
>> > advice
>> > or clue on how to do this? Thank you so much.
>> >
>> > import java.io.*;
>> >
>> > public class HelloWorld {
>> > public static String HelloWorldNormal = "HelloWorld--normal";
>> > public static volatile String HelloWorldVolatile =
>> > "HelloWorld--volatile";
>> > private static ThreadLocal <String> HelloWorldThreadLocal = new
>> > ThreadLocal(){
>> > protected String initialValue(){
>> > return new String("HelloWorld--threadlocal");
>> > }
>> > };
>> >
>> > public static void main(String[] arg) {
>> > HelloWorld item = new HelloWorld();
>> > System.out.println( item.HelloWorldNormal );
>> > System.out.println( item.HelloWorldVolatile );
>> > // System.out.println( item.HelloWorldThreadLocal.get());
>> > }
>> > }
>> >
>> >
>> > _______________________________________________
>> > 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