soot.jimple.toolkits.invoke
Class SynchronizerManager

java.lang.Object
  |
  +--soot.jimple.toolkits.invoke.SynchronizerManager

public class SynchronizerManager
extends java.lang.Object

Utility methods for dealing with synchronization.


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

Field Detail

classToClassField

public static java.util.HashMap classToClassField
Maps classes to class$ fields. Don't trust default.

Constructor Detail

SynchronizerManager

public SynchronizerManager()
Method Detail

addStmtsToFetchClassBefore

public static 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 static 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 static SootMethod createClassFetcherFor(SootClass c,
                                               java.lang.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 static 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.