[Soot-list] ThreadLocal class

yi zhang cathy.zhyi at gmail.com
Sat Jul 24 11:53:53 EDT 2010


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());
    }
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20100724/f9735c87/attachment.html 


More information about the Soot-list mailing list