Class SynchronizerManager


  • public class SynchronizerManager
    extends Object
    Utility methods for dealing with synchronization.
    • Field Detail

      • classToClassField

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

      • addStmtsToFetchClassBefore

        public Local addStmtsToFetchClassBefore​(JimpleBody b,
                                                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:
         
      • addStmtsToFetchClassBefore

        public Local addStmtsToFetchClassBefore​(ShimpleBody b,
                                                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,
                                             boolean createNewAsShimple)
        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,
                                                boolean createNewAsShimple)
        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.
      • synchronizeStmtOn

        public void synchronizeStmtOn​(Stmt stmt,
                                      ShimpleBody 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.