Program: 88795
Project: 88795
Buggy source:
protected void internalTransform(String phaseName,Map opts){
  SMBOptions options=new SMBOptions(opts);
  String modifierOptions=PhaseOptions.getString(opts,"String_Node_Str");
  HashMap instanceToStaticMap=new HashMap();
  CallGraph cg=Scene.v().getCallGraph();
  Hierarchy hierarchy=Scene.v().getActiveHierarchy();
  Iterator classesIt=Scene.v().getApplicationClasses().iterator();
  while (classesIt.hasNext()) {
    SootClass c=(SootClass)classesIt.next();
    LinkedList methodsList=new LinkedList();
    for (Iterator it=c.methodIterator(); it.hasNext(); ) {
      methodsList.add(it.next());
    }
    while (!methodsList.isEmpty()) {
      SootMethod container=(SootMethod)methodsList.removeFirst();
      if (!container.isConcrete())       continue;
      if (!cg.targetsOf(container).hasNext())       continue;
      JimpleBody b=(JimpleBody)container.getActiveBody();
      List unitList=new ArrayList();
      unitList.addAll(b.getUnits());
      Iterator unitIt=unitList.iterator();
      while (unitIt.hasNext()) {
        Stmt s=(Stmt)unitIt.next();
        if (!s.containsInvokeExpr())         continue;
        InvokeExpr ie=(InvokeExpr)s.getInvokeExpr();
        if (ie instanceof StaticInvokeExpr || ie instanceof SpecialInvokeExpr)         continue;
        Iterator targets=new Targets(cg.targetsOf(s));
        if (!targets.hasNext())         continue;
        SootMethod target=(SootMethod)targets.next();
        if (targets.hasNext())         continue;
        if (!AccessManager.ensureAccess(container,target,modifierOptions))         continue;
        if (!target.getDeclaringClass().isApplicationClass() || !target.isConcrete())         continue;
        if (target.getDeclaringClass() == Scene.v().getSootClass("String_Node_Str"))         continue;
        boolean targetUsesThis=true;
        if (!instanceToStaticMap.containsKey(target)) {
          List newParameterTypes=new ArrayList();
          if (targetUsesThis)           newParameterTypes.add(RefType.v(target.getDeclaringClass().getName()));
          newParameterTypes.addAll(target.getParameterTypes());
          String newName=target.getName() + "String_Node_Str";
          while (target.getDeclaringClass().declaresMethod(newName,newParameterTypes,target.getReturnType()))           newName=newName + "String_Node_Str";
          SootMethod ct=new SootMethod(newName,newParameterTypes,target.getReturnType(),target.getModifiers() | Modifier.STATIC,target.getExceptions());
          target.getDeclaringClass().addMethod(ct);
          methodsList.addLast(ct);
          ct.setActiveBody((Body)target.getActiveBody().clone());
{
            Iterator oldUnits=target.getActiveBody().getUnits().iterator();
            Iterator newUnits=ct.getActiveBody().getUnits().iterator();
            while (newUnits.hasNext()) {
              Stmt oldStmt, newStmt;
              oldStmt=(Stmt)oldUnits.next();
              newStmt=(Stmt)newUnits.next();
              Iterator edges=cg.targetsOf(oldStmt);
              while (edges.hasNext()) {
                Edge e=(Edge)edges.next();
                cg.addEdge(new Edge(ct,newStmt,e.tgt(),e.kind()));
                cg.removeEdge(e);
              }
            }
          }
{
            Body newBody=ct.getActiveBody();
            Chain units=newBody.getUnits();
            Iterator unitsIt=newBody.getUnits().snapshotIterator();
            while (unitsIt.hasNext()) {
              Stmt st=(Stmt)unitsIt.next();
              if (st instanceof IdentityStmt) {
                IdentityStmt is=(IdentityStmt)st;
                if (is.getRightOp() instanceof ThisRef) {
                  if (targetUsesThis)                   units.swapWith(st,Jimple.v().newIdentityStmt(is.getLeftOp(),Jimple.v().newParameterRef(is.getRightOp().getType(),0)));
 else {
                    units.remove(st);
                    break;
                  }
                }
 else                 if (targetUsesThis) {
                  if (is.getRightOp() instanceof ParameterRef) {
                    ParameterRef ro=(ParameterRef)is.getRightOp();
                    ro.setIndex(ro.getIndex() + 1);
                  }
                }
              }
            }
          }
          instanceToStaticMap.put(target,ct);
        }
        SootMethod clonedTarget=(SootMethod)instanceToStaticMap.get(target);
        Value thisToAdd=((InstanceInvokeExpr)ie).getBase();
        if (options.insert_redundant_casts() && targetUsesThis) {
          SootClass localType, parameterType;
          localType=((RefType)((InstanceInvokeExpr)ie).getBase().getType()).getSootClass();
          parameterType=target.getDeclaringClass();
          if (localType.isInterface() || hierarchy.isClassSuperclassOf(localType,parameterType)) {
            Local castee=Jimple.v().newLocal("String_Node_Str",parameterType.getType());
            b.getLocals().add(castee);
            b.getUnits().insertBefore(Jimple.v().newAssignStmt(castee,Jimple.v().newCastExpr(((InstanceInvokeExpr)ie).getBase(),parameterType.getType())),s);
            thisToAdd=castee;
          }
        }
{
          List newArgs=new ArrayList();
          if (targetUsesThis)           newArgs.add(thisToAdd);
          newArgs.addAll(ie.getArgs());
          StaticInvokeExpr sie=Jimple.v().newStaticInvokeExpr(clonedTarget,newArgs);
          ValueBox ieBox=s.getInvokeExprBox();
          ieBox.setValue(sie);
          cg.addEdge(new Edge(container,s,clonedTarget));
        }
        if (options.insert_null_checks()) {
          boolean caught=TrapManager.isExceptionCaughtAt(Scene.v().getSootClass("String_Node_Str"),s,b);
          if (caught) {
            Stmt insertee=Jimple.v().newIfStmt(Jimple.v().newNeExpr(((InstanceInvokeExpr)ie).getBase(),NullConstant.v()),s);
            b.getUnits().insertBefore(insertee,s);
            ((IfStmt)insertee).setTarget(s);
            ThrowManager.addThrowAfter(b,insertee);
          }
 else {
            Stmt throwPoint=ThrowManager.getNullPointerExceptionThrower(b);
            b.getUnits().insertBefore(Jimple.v().newIfStmt(Jimple.v().newEqExpr(((InstanceInvokeExpr)ie).getBase(),NullConstant.v()),throwPoint),s);
          }
        }
{
          if (target.isSynchronized()) {
            clonedTarget.setModifiers(clonedTarget.getModifiers() & ~Modifier.SYNCHRONIZED);
            SynchronizerManager.v().synchronizeStmtOn(s,b,(Local)((InstanceInvokeExpr)ie).getBase());
          }
        }
        LocalNameStandardizer.v().transform(b,phaseName + "String_Node_Str");
      }
    }
  }
}

Fixed version (ground truth):
protected void internalTransform(String phaseName,Map opts){
  Filter instanceInvokesFilter=new Filter(new InstanceInvokeEdgesPred());
  SMBOptions options=new SMBOptions(opts);
  String modifierOptions=PhaseOptions.getString(opts,"String_Node_Str");
  HashMap instanceToStaticMap=new HashMap();
  CallGraph cg=Scene.v().getCallGraph();
  Hierarchy hierarchy=Scene.v().getActiveHierarchy();
  Iterator classesIt=Scene.v().getApplicationClasses().iterator();
  while (classesIt.hasNext()) {
    SootClass c=(SootClass)classesIt.next();
    LinkedList methodsList=new LinkedList();
    for (Iterator it=c.methodIterator(); it.hasNext(); ) {
      methodsList.add(it.next());
    }
    while (!methodsList.isEmpty()) {
      SootMethod container=(SootMethod)methodsList.removeFirst();
      if (!container.isConcrete())       continue;
      if (!instanceInvokesFilter.wrap(cg.targetsOf(container)).hasNext())       continue;
      JimpleBody b=(JimpleBody)container.getActiveBody();
      List unitList=new ArrayList();
      unitList.addAll(b.getUnits());
      Iterator unitIt=unitList.iterator();
      while (unitIt.hasNext()) {
        Stmt s=(Stmt)unitIt.next();
        if (!s.containsInvokeExpr())         continue;
        InvokeExpr ie=(InvokeExpr)s.getInvokeExpr();
        if (ie instanceof StaticInvokeExpr || ie instanceof SpecialInvokeExpr)         continue;
        Iterator targets=new Targets(instanceInvokesFilter.wrap(cg.targetsOf(s)));
        if (!targets.hasNext())         continue;
        SootMethod target=(SootMethod)targets.next();
        if (targets.hasNext())         continue;
        if (!AccessManager.ensureAccess(container,target,modifierOptions))         continue;
        if (!target.getDeclaringClass().isApplicationClass() || !target.isConcrete())         continue;
        if (target.getDeclaringClass() == Scene.v().getSootClass("String_Node_Str"))         continue;
        boolean targetUsesThis=true;
        if (!instanceToStaticMap.containsKey(target)) {
          List newParameterTypes=new ArrayList();
          if (targetUsesThis)           newParameterTypes.add(RefType.v(target.getDeclaringClass().getName()));
          newParameterTypes.addAll(target.getParameterTypes());
          String newName=target.getName() + "String_Node_Str";
          while (target.getDeclaringClass().declaresMethod(newName,newParameterTypes,target.getReturnType()))           newName=newName + "String_Node_Str";
          SootMethod ct=new SootMethod(newName,newParameterTypes,target.getReturnType(),target.getModifiers() | Modifier.STATIC,target.getExceptions());
          target.getDeclaringClass().addMethod(ct);
          methodsList.addLast(ct);
          ct.setActiveBody((Body)target.getActiveBody().clone());
{
            Iterator oldUnits=target.getActiveBody().getUnits().iterator();
            Iterator newUnits=ct.getActiveBody().getUnits().iterator();
            while (newUnits.hasNext()) {
              Stmt oldStmt, newStmt;
              oldStmt=(Stmt)oldUnits.next();
              newStmt=(Stmt)newUnits.next();
              Iterator edges=cg.targetsOf(oldStmt);
              while (edges.hasNext()) {
                Edge e=(Edge)edges.next();
                cg.addEdge(new Edge(ct,newStmt,e.tgt(),e.kind()));
                cg.removeEdge(e);
              }
            }
          }
{
            Body newBody=ct.getActiveBody();
            Chain units=newBody.getUnits();
            Iterator unitsIt=newBody.getUnits().snapshotIterator();
            while (unitsIt.hasNext()) {
              Stmt st=(Stmt)unitsIt.next();
              if (st instanceof IdentityStmt) {
                IdentityStmt is=(IdentityStmt)st;
                if (is.getRightOp() instanceof ThisRef) {
                  if (targetUsesThis)                   units.swapWith(st,Jimple.v().newIdentityStmt(is.getLeftOp(),Jimple.v().newParameterRef(is.getRightOp().getType(),0)));
 else {
                    units.remove(st);
                    break;
                  }
                }
 else                 if (targetUsesThis) {
                  if (is.getRightOp() instanceof ParameterRef) {
                    ParameterRef ro=(ParameterRef)is.getRightOp();
                    ro.setIndex(ro.getIndex() + 1);
                  }
                }
              }
            }
          }
          instanceToStaticMap.put(target,ct);
        }
        SootMethod clonedTarget=(SootMethod)instanceToStaticMap.get(target);
        Value thisToAdd=((InstanceInvokeExpr)ie).getBase();
        if (options.insert_redundant_casts() && targetUsesThis) {
          SootClass localType, parameterType;
          localType=((RefType)((InstanceInvokeExpr)ie).getBase().getType()).getSootClass();
          parameterType=target.getDeclaringClass();
          if (localType.isInterface() || hierarchy.isClassSuperclassOf(localType,parameterType)) {
            Local castee=Jimple.v().newLocal("String_Node_Str",parameterType.getType());
            b.getLocals().add(castee);
            b.getUnits().insertBefore(Jimple.v().newAssignStmt(castee,Jimple.v().newCastExpr(((InstanceInvokeExpr)ie).getBase(),parameterType.getType())),s);
            thisToAdd=castee;
          }
        }
{
          List newArgs=new ArrayList();
          if (targetUsesThis)           newArgs.add(thisToAdd);
          newArgs.addAll(ie.getArgs());
          StaticInvokeExpr sie=Jimple.v().newStaticInvokeExpr(clonedTarget,newArgs);
          ValueBox ieBox=s.getInvokeExprBox();
          ieBox.setValue(sie);
          cg.addEdge(new Edge(container,s,clonedTarget));
        }
        if (options.insert_null_checks()) {
          boolean caught=TrapManager.isExceptionCaughtAt(Scene.v().getSootClass("String_Node_Str"),s,b);
          if (caught) {
            Stmt insertee=Jimple.v().newIfStmt(Jimple.v().newNeExpr(((InstanceInvokeExpr)ie).getBase(),NullConstant.v()),s);
            b.getUnits().insertBefore(insertee,s);
            ((IfStmt)insertee).setTarget(s);
            ThrowManager.addThrowAfter(b,insertee);
          }
 else {
            Stmt throwPoint=ThrowManager.getNullPointerExceptionThrower(b);
            b.getUnits().insertBefore(Jimple.v().newIfStmt(Jimple.v().newEqExpr(((InstanceInvokeExpr)ie).getBase(),NullConstant.v()),throwPoint),s);
          }
        }
{
          if (target.isSynchronized()) {
            clonedTarget.setModifiers(clonedTarget.getModifiers() & ~Modifier.SYNCHRONIZED);
            SynchronizerManager.v().synchronizeStmtOn(s,b,(Local)((InstanceInvokeExpr)ie).getBase());
          }
        }
        LocalNameStandardizer.v().transform(b,phaseName + "String_Node_Str");
      }
    }
  }
}