soot.jimple.toolkits.invoke
Class SynchronizerManager

java.lang.Object
  extended by soot.jimple.toolkits.invoke.SynchronizerManager

public class SynchronizerManager
extends Object

Utility methods for dealing with synchronization.


Field Summary
 HashMap<SootClass,SootField> classToClassField
          Maps classes to class$ fields.
 
Constructor Summary
SynchronizerManager(Singletons.Global g)
           
 
Method Summary
 Local addStmtsToFetchClassBefore(JimpleBody jb, Stmt target)
          Adds code to fetch the static Class object to the given JimpleBody before the target Stmt.
 SootMethod createClassFetcherFor(SootClass c, String methodName)
          Creates a method which calls java.lang.Class.forName(String).
 SootMethod getClassFetcherFor(SootClass c)
          Finds a method which calls java.lang.Class.forName(String).
 void synchronizeStmtOn(Stmt stmt, JimpleBody b, Local lock)
          Wraps stmt around a monitor associated with local lock.
static SynchronizerManager v()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

classToClassField

public HashMap<SootClass,SootField> classToClassField
Maps classes to class$ fields. Don't trust default.

Constructor Detail

SynchronizerManager

public SynchronizerManager(Singletons.Global g)
Method Detail

v

public static SynchronizerManager v()

addStmtsToFetchClassBefore

public Local addStmtsToFetchClassBefore(JimpleBody jb,
                                        Stmt target)
Adds code to fetch the static Class object to the given JimpleBody before the target Stmt. Uses our custom classToClassField field to cache the results. The code will look like this:
        $r3 = ;
        .if $r3 != .null .goto label2;

        $r3 = .staticinvoke ("quack");
         = $r3;

     label2:


getClassFetcherFor

public SootMethod getClassFetcherFor(SootClass c)
Finds a method which calls java.lang.Class.forName(String). Searches for names class$, _class$, __class$, etc. If no such method is found, creates one and returns it. Uses dumb matching to do search. Not worth doing symbolic analysis for this!


createClassFetcherFor

public SootMethod createClassFetcherFor(SootClass c,
                                        String methodName)
Creates a method which calls java.lang.Class.forName(String). The method should look like the following:
         .static java.lang.Class class$(java.lang.String)
         {
             java.lang.String r0, $r5;
             java.lang.ClassNotFoundException r1, $r3;
             java.lang.Class $r2;
             java.lang.NoClassDefFoundError $r4;

             r0 := @parameter0: java.lang.String;

         label0:
             $r2 = .staticinvoke (r0);
             .return $r2;

         label1:
             $r3 := @caughtexception;
             r1 = $r3;
             $r4 = .new java.lang.NoClassDefFoundError;
             $r5 = .virtualinvoke r1.();
             .specialinvoke $r4.(java.lang.String)>($r5);
             .throw $r4;

             .catch java.lang.ClassNotFoundException .from label0 .to label1 .with label1;
         }


synchronizeStmtOn

public void synchronizeStmtOn(Stmt stmt,
                              JimpleBody b,
                              Local lock)
Wraps stmt around a monitor associated with local lock. When inlining or static method binding, this is the former base of the invoke expression.