Program: 75258
Project: 75258
Buggy source:
protected void internalTransform(String phaseName,Map options){
  int localCount=0;
  System.out.println("String_Node_Str" + phaseName + "String_Node_Str"+ options+ "String_Node_Str");
  for (Iterator i=Scene.v().getApplicationClasses().iterator(); i.hasNext(); ) {
    SootClass theClass=(SootClass)i.next();
    for (Iterator methods=theClass.getMethods().iterator(); methods.hasNext(); ) {
      SootMethod method=(SootMethod)methods.next();
      JimpleBody body=(JimpleBody)method.retrieveActiveBody();
      for (Iterator units=body.getUnits().snapshotIterator(); units.hasNext(); ) {
        Stmt unit=(Stmt)units.next();
        if (unit.containsFieldRef()) {
          ValueBox box=unit.getFieldRefBox();
          Value value=box.getValue();
          if (value instanceof InstanceFieldRef) {
            InstanceFieldRef fieldRef=(InstanceFieldRef)value;
            SootField field=fieldRef.getField();
            if (field.getSubSignature().equals(PtolemyUtilities.debuggingField.getSubSignature())) {
              if (unit instanceof AssignStmt) {
                body.getUnits().insertBefore(Jimple.v().newAssignStmt(((AssignStmt)unit).getLeftOp(),IntConstant.v(0)),unit);
              }
              body.getUnits().remove(unit);
            }
          }
        }
 else         if (unit.containsInvokeExpr()) {
          ValueBox box=unit.getInvokeExprBox();
          Value value=box.getValue();
          if ((value instanceof InvokeExpr) && !(value instanceof SpecialInvokeExpr)) {
            InvokeExpr expr=(InvokeExpr)value;
            if (expr.getMethod().getSubSignature().equals(PtolemyUtilities.attachTextMethod.getSubSignature())) {
              body.getUnits().remove(unit);
            }
 else             if (expr.getMethod().getSubSignature().equals(PtolemyUtilities.setNameMethod.getSubSignature())) {
              body.getUnits().remove(unit);
            }
 else             if (expr.getMethod().getName().equals("String_Node_Str")) {
              body.getUnits().remove(unit);
            }
            if (expr.getMethod().getSubSignature().equals(PtolemyUtilities.getFullNameMethod.getSubSignature())) {
              if (unit instanceof AssignStmt) {
                body.getUnits().insertBefore(Jimple.v().newAssignStmt(((AssignStmt)unit).getLeftOp(),StringConstant.v(_model.getFullName())),unit);
              }
              body.getUnits().remove(unit);
            }
 else             if (expr.getMethod().getSubSignature().equals(PtolemyUtilities.getNameMethod.getSubSignature())) {
              if (unit instanceof AssignStmt) {
                body.getUnits().insertBefore(Jimple.v().newAssignStmt(((AssignStmt)unit).getLeftOp(),StringConstant.v(_model.getName())),unit);
              }
              body.getUnits().remove(unit);
            }
 else             if (expr.getMethod().getSubSignature().equals(PtolemyUtilities.findEffigyMethod.getSubSignature())) {
              if (unit instanceof AssignStmt) {
                body.getUnits().insertBefore(Jimple.v().newAssignStmt(((AssignStmt)unit).getLeftOp(),NullConstant.v()),unit);
              }
              body.getUnits().remove(unit);
            }
 else             if (expr.getMethod().getSubSignature().equals(PtolemyUtilities.getModelURIMethod.getSubSignature())) {
              if (unit instanceof AssignStmt) {
                SootClass uriClass=Scene.v().loadClassAndSupport("String_Node_Str");
                RefType type=RefType.v(uriClass);
                SootMethod initMethod=uriClass.getMethod("String_Node_Str");
                Local local=(Local)((AssignStmt)unit).getLeftOp();
                String uriString=URIAttribute.getModelURI(_model).toString();
                body.getUnits().insertBefore(Jimple.v().newAssignStmt(local,Jimple.v().newNewExpr(type)),unit);
                body.getUnits().insertBefore(Jimple.v().newInvokeStmt(Jimple.v().newSpecialInvokeExpr(local,initMethod,StringConstant.v(uriString))),unit);
              }
              body.getUnits().remove(unit);
            }
 else             if (expr.getMethod().getSubSignature().equals(PtolemyUtilities.handleModelErrorMethod.getSubSignature())) {
              body.getUnits().insertBefore(Jimple.v().newThrowStmt(expr.getArg(1)),unit);
              body.getUnits().remove(unit);
            }
          }
        }
      }
    }
  }
  List modifiedConstructorClassList=new LinkedList();
  for (Iterator i=Scene.v().getApplicationClasses().iterator(); i.hasNext(); ) {
    SootClass theClass=(SootClass)i.next();
    if (SootUtilities.derivesFrom(theClass,PtolemyUtilities.actorClass) || SootUtilities.derivesFrom(theClass,PtolemyUtilities.compositeActorClass) || SootUtilities.derivesFrom(theClass,PtolemyUtilities.attributeClass)) {
      theClass.setSuperclass(PtolemyUtilities.objectClass);
      SootMethod method=null;
      try {
        method=theClass.getMethodByName("String_Node_Str");
      }
 catch (      RuntimeException ex) {
        System.out.println("String_Node_Str" + "String_Node_Str" + theClass);
        System.out.println("String_Node_Str" + theClass.getMethods());
        throw ex;
      }
      if (method.getParameterCount() == 2) {
        SootField containerField=theClass.getFieldByName(ModelTransformer.getContainerFieldName());
        RefType containerType=(RefType)containerField.getType();
        List typeList=new LinkedList();
        typeList.add(containerType);
        method.setParameterTypes(typeList);
      }
 else {
        method.setParameterTypes(Collections.EMPTY_LIST);
      }
      modifiedConstructorClassList.add(theClass);
      theClass.removeMethod(method);
      theClass.addMethod(method);
      JimpleBody body=(JimpleBody)method.retrieveActiveBody();
      for (Iterator units=body.getUnits().snapshotIterator(); units.hasNext(); ) {
        Stmt unit=(Stmt)units.next();
        if (unit.containsInvokeExpr()) {
          ValueBox box=unit.getInvokeExprBox();
          Value value=box.getValue();
          if (value instanceof SpecialInvokeExpr) {
            SpecialInvokeExpr expr=(SpecialInvokeExpr)value;
            if (expr.getBase().equals(body.getThisLocal()) && expr.getMethod().getName().equals("String_Node_Str")) {
              box.setValue(Jimple.v().newSpecialInvokeExpr((Local)expr.getBase(),PtolemyUtilities.objectConstructor,Collections.EMPTY_LIST));
            }
          }
        }
 else         if (unit instanceof IdentityStmt) {
          IdentityStmt identityStmt=(IdentityStmt)unit;
          Value value=identityStmt.getRightOp();
          if (value instanceof ParameterRef) {
            ParameterRef parameterRef=(ParameterRef)value;
            if (parameterRef.getIndex() == 0 && method.getParameterCount() == 1) {
              ValueBox box=identityStmt.getRightOpBox();
              box.setValue(Jimple.v().newParameterRef(method.getParameterType(0),0));
            }
 else {
              body.getUnits().remove(identityStmt);
              body.getUnits().insertBefore(Jimple.v().newAssignStmt(identityStmt.getLeftOp(),NullConstant.v()),body.getFirstNonIdentityStmt());
            }
          }
        }
      }
    }
  }
  Scene.v().setActiveHierarchy(new Hierarchy());
  Scene.v().setFastHierarchy(new FastHierarchy());
  for (Iterator i=Scene.v().getApplicationClasses().iterator(); i.hasNext(); ) {
    SootClass theClass=(SootClass)i.next();
    for (Iterator methods=theClass.getMethods().iterator(); methods.hasNext(); ) {
      SootMethod method=(SootMethod)methods.next();
      JimpleBody body=(JimpleBody)method.retrieveActiveBody();
      for (Iterator units=body.getUnits().snapshotIterator(); units.hasNext(); ) {
        Stmt unit=(Stmt)units.next();
        if (unit.containsInvokeExpr()) {
          ValueBox box=unit.getInvokeExprBox();
          Value value=box.getValue();
          if (value instanceof SpecialInvokeExpr) {
            SpecialInvokeExpr expr=(SpecialInvokeExpr)value;
            SootClass declaringClass=expr.getMethod().getDeclaringClass();
            if (expr.getMethod().getName().equals("String_Node_Str") && modifiedConstructorClassList.contains(declaringClass)) {
              SootMethod newConstructor=declaringClass.getMethodByName("String_Node_Str");
              if (newConstructor.getParameterCount() == 1) {
                List args=new LinkedList();
                args.add(expr.getArg(0));
                box.setValue(Jimple.v().newSpecialInvokeExpr((Local)expr.getBase(),newConstructor,args));
              }
 else {
                box.setValue(Jimple.v().newSpecialInvokeExpr((Local)expr.getBase(),newConstructor,Collections.EMPTY_LIST));
              }
            }
          }
        }
      }
    }
  }
  for (Iterator i=Scene.v().getApplicationClasses().iterator(); i.hasNext(); ) {
    SootClass theClass=(SootClass)i.next();
    for (Iterator methods=theClass.getMethods().iterator(); methods.hasNext(); ) {
      SootMethod method=(SootMethod)methods.next();
      JimpleBody body=(JimpleBody)method.retrieveActiveBody();
      LocalSplitter.v().transform(body,"String_Node_Str");
      TypeAssigner.v().transform(body,"String_Node_Str");
      for (Iterator units=body.getUnits().snapshotIterator(); units.hasNext(); ) {
        Stmt unit=(Stmt)units.next();
        for (Iterator boxes=unit.getUseAndDefBoxes().iterator(); boxes.hasNext(); ) {
          ValueBox box=(ValueBox)boxes.next();
          Value value=box.getValue();
          Type type=value.getType();
          if (_isRemovableType(type)) {
            body.getUnits().remove(unit);
            break;
          }
        }
        for (Iterator locals=body.getLocals().snapshotIterator(); locals.hasNext(); ) {
          Local local=(Local)locals.next();
          Type type=local.getType();
          if (_isRemovableType(type)) {
            body.getLocals().remove(local);
          }
        }
      }
      for (Iterator fields=theClass.getFields().snapshotIterator(); fields.hasNext(); ) {
        SootField field=(SootField)fields.next();
        Type type=field.getType();
        if (_isRemovableType(type)) {
          theClass.getFields().remove(field);
        }
      }
    }
  }
  for (Iterator i=Scene.v().getApplicationClasses().iterator(); i.hasNext(); ) {
    SootClass theClass=(SootClass)i.next();
    for (Iterator interfaces=theClass.getInterfaces().snapshotIterator(); interfaces.hasNext(); ) {
      SootClass theInterface=(SootClass)interfaces.next();
      if (theInterface.equals(PtolemyUtilities.inequalityTermClass)) {
        theClass.getInterfaces().remove(theInterface);
      }
      if (theInterface.equals(PtolemyUtilities.explicitChangeContextClass)) {
        theClass.getInterfaces().remove(theInterface);
      }
    }
  }
}

Fixed version (ground truth):
protected void internalTransform(String phaseName,Map options){
  int localCount=0;
  System.out.println("String_Node_Str" + phaseName + "String_Node_Str"+ options+ "String_Node_Str");
  for (Iterator i=Scene.v().getApplicationClasses().iterator(); i.hasNext(); ) {
    SootClass theClass=(SootClass)i.next();
    for (Iterator methods=theClass.getMethods().iterator(); methods.hasNext(); ) {
      SootMethod method=(SootMethod)methods.next();
      JimpleBody body=(JimpleBody)method.retrieveActiveBody();
      for (Iterator units=body.getUnits().snapshotIterator(); units.hasNext(); ) {
        Stmt unit=(Stmt)units.next();
        if (unit.containsFieldRef()) {
          ValueBox box=unit.getFieldRefBox();
          Value value=box.getValue();
          if (value instanceof InstanceFieldRef) {
            InstanceFieldRef fieldRef=(InstanceFieldRef)value;
            SootField field=fieldRef.getField();
            if (field.getSubSignature().equals(PtolemyUtilities.debuggingField.getSubSignature())) {
              if (unit instanceof AssignStmt) {
                body.getUnits().insertBefore(Jimple.v().newAssignStmt(((AssignStmt)unit).getLeftOp(),IntConstant.v(0)),unit);
              }
              body.getUnits().remove(unit);
            }
 else             if (field.getSubSignature().equals(PtolemyUtilities.stopRequestedField.getSubSignature())) {
              if (unit instanceof AssignStmt && box == ((AssignStmt)unit).getLeftOpBox()) {
                body.getUnits().remove(unit);
              }
 else {
                box.setValue(IntConstant.v(0));
              }
            }
          }
        }
 else         if (unit.containsInvokeExpr()) {
          ValueBox box=unit.getInvokeExprBox();
          Value value=box.getValue();
          if ((value instanceof InvokeExpr) && !(value instanceof SpecialInvokeExpr)) {
            InvokeExpr expr=(InvokeExpr)value;
            if (expr.getMethod().getSubSignature().equals(PtolemyUtilities.attachTextMethod.getSubSignature())) {
              body.getUnits().remove(unit);
            }
 else             if (expr.getMethod().getSubSignature().equals(PtolemyUtilities.setNameMethod.getSubSignature())) {
              body.getUnits().remove(unit);
            }
 else             if (expr.getMethod().getName().equals("String_Node_Str")) {
              body.getUnits().remove(unit);
            }
            if (expr.getMethod().getSubSignature().equals(PtolemyUtilities.getFullNameMethod.getSubSignature())) {
              if (unit instanceof AssignStmt) {
                body.getUnits().insertBefore(Jimple.v().newAssignStmt(((AssignStmt)unit).getLeftOp(),StringConstant.v(_model.getFullName())),unit);
              }
              body.getUnits().remove(unit);
            }
 else             if (expr.getMethod().getSubSignature().equals(PtolemyUtilities.getNameMethod.getSubSignature())) {
              if (unit instanceof AssignStmt) {
                body.getUnits().insertBefore(Jimple.v().newAssignStmt(((AssignStmt)unit).getLeftOp(),StringConstant.v(_model.getName())),unit);
              }
              body.getUnits().remove(unit);
            }
 else             if (expr.getMethod().getSubSignature().equals(PtolemyUtilities.findEffigyMethod.getSubSignature())) {
              if (unit instanceof AssignStmt) {
                body.getUnits().insertBefore(Jimple.v().newAssignStmt(((AssignStmt)unit).getLeftOp(),NullConstant.v()),unit);
              }
              body.getUnits().remove(unit);
            }
 else             if (expr.getMethod().getSubSignature().equals(PtolemyUtilities.getModelURIMethod.getSubSignature())) {
              if (unit instanceof AssignStmt) {
                SootClass uriClass=Scene.v().loadClassAndSupport("String_Node_Str");
                RefType type=RefType.v(uriClass);
                SootMethod initMethod=uriClass.getMethod("String_Node_Str");
                Local local=(Local)((AssignStmt)unit).getLeftOp();
                String uriString=URIAttribute.getModelURI(_model).toString();
                body.getUnits().insertBefore(Jimple.v().newAssignStmt(local,Jimple.v().newNewExpr(type)),unit);
                body.getUnits().insertBefore(Jimple.v().newInvokeStmt(Jimple.v().newSpecialInvokeExpr(local,initMethod,StringConstant.v(uriString))),unit);
              }
              body.getUnits().remove(unit);
            }
 else             if (expr.getMethod().getSubSignature().equals(PtolemyUtilities.handleModelErrorMethod.getSubSignature())) {
              body.getUnits().insertBefore(Jimple.v().newThrowStmt(expr.getArg(1)),unit);
              body.getUnits().remove(unit);
            }
          }
        }
      }
    }
  }
  List modifiedConstructorClassList=new LinkedList();
  for (Iterator i=Scene.v().getApplicationClasses().iterator(); i.hasNext(); ) {
    SootClass theClass=(SootClass)i.next();
    if (SootUtilities.derivesFrom(theClass,PtolemyUtilities.actorClass) || SootUtilities.derivesFrom(theClass,PtolemyUtilities.compositeActorClass) || SootUtilities.derivesFrom(theClass,PtolemyUtilities.attributeClass)) {
      theClass.setSuperclass(PtolemyUtilities.objectClass);
      SootMethod method=null;
      try {
        method=theClass.getMethodByName("String_Node_Str");
      }
 catch (      RuntimeException ex) {
        System.out.println("String_Node_Str" + "String_Node_Str" + theClass);
        System.out.println("String_Node_Str" + theClass.getMethods());
        throw ex;
      }
      if (method.getParameterCount() == 2) {
        SootField containerField=theClass.getFieldByName(ModelTransformer.getContainerFieldName());
        RefType containerType=(RefType)containerField.getType();
        List typeList=new LinkedList();
        typeList.add(containerType);
        method.setParameterTypes(typeList);
      }
 else {
        method.setParameterTypes(Collections.EMPTY_LIST);
      }
      modifiedConstructorClassList.add(theClass);
      theClass.removeMethod(method);
      theClass.addMethod(method);
      JimpleBody body=(JimpleBody)method.retrieveActiveBody();
      for (Iterator units=body.getUnits().snapshotIterator(); units.hasNext(); ) {
        Stmt unit=(Stmt)units.next();
        if (unit.containsInvokeExpr()) {
          ValueBox box=unit.getInvokeExprBox();
          Value value=box.getValue();
          if (value instanceof SpecialInvokeExpr) {
            SpecialInvokeExpr expr=(SpecialInvokeExpr)value;
            if (expr.getBase().equals(body.getThisLocal()) && expr.getMethod().getName().equals("String_Node_Str")) {
              box.setValue(Jimple.v().newSpecialInvokeExpr((Local)expr.getBase(),PtolemyUtilities.objectConstructor,Collections.EMPTY_LIST));
            }
          }
        }
 else         if (unit instanceof IdentityStmt) {
          IdentityStmt identityStmt=(IdentityStmt)unit;
          Value value=identityStmt.getRightOp();
          if (value instanceof ParameterRef) {
            ParameterRef parameterRef=(ParameterRef)value;
            if (parameterRef.getIndex() == 0 && method.getParameterCount() == 1) {
              ValueBox box=identityStmt.getRightOpBox();
              box.setValue(Jimple.v().newParameterRef(method.getParameterType(0),0));
            }
 else {
              body.getUnits().remove(identityStmt);
              body.getUnits().insertBefore(Jimple.v().newAssignStmt(identityStmt.getLeftOp(),NullConstant.v()),body.getFirstNonIdentityStmt());
            }
          }
        }
      }
    }
  }
  Scene.v().setActiveHierarchy(new Hierarchy());
  Scene.v().setFastHierarchy(new FastHierarchy());
  for (Iterator i=Scene.v().getApplicationClasses().iterator(); i.hasNext(); ) {
    SootClass theClass=(SootClass)i.next();
    for (Iterator methods=theClass.getMethods().iterator(); methods.hasNext(); ) {
      SootMethod method=(SootMethod)methods.next();
      JimpleBody body=(JimpleBody)method.retrieveActiveBody();
      for (Iterator units=body.getUnits().snapshotIterator(); units.hasNext(); ) {
        Stmt unit=(Stmt)units.next();
        if (unit.containsInvokeExpr()) {
          ValueBox box=unit.getInvokeExprBox();
          Value value=box.getValue();
          if (value instanceof SpecialInvokeExpr) {
            SpecialInvokeExpr expr=(SpecialInvokeExpr)value;
            SootClass declaringClass=expr.getMethod().getDeclaringClass();
            if (expr.getMethod().getName().equals("String_Node_Str") && modifiedConstructorClassList.contains(declaringClass)) {
              SootMethod newConstructor=declaringClass.getMethodByName("String_Node_Str");
              if (newConstructor.getParameterCount() == 1) {
                List args=new LinkedList();
                args.add(expr.getArg(0));
                box.setValue(Jimple.v().newSpecialInvokeExpr((Local)expr.getBase(),newConstructor,args));
              }
 else {
                box.setValue(Jimple.v().newSpecialInvokeExpr((Local)expr.getBase(),newConstructor,Collections.EMPTY_LIST));
              }
            }
          }
        }
      }
    }
  }
  for (Iterator i=Scene.v().getApplicationClasses().iterator(); i.hasNext(); ) {
    SootClass theClass=(SootClass)i.next();
    for (Iterator methods=theClass.getMethods().iterator(); methods.hasNext(); ) {
      SootMethod method=(SootMethod)methods.next();
      JimpleBody body=(JimpleBody)method.retrieveActiveBody();
      LocalSplitter.v().transform(body,"String_Node_Str");
      TypeAssigner.v().transform(body,"String_Node_Str");
      for (Iterator units=body.getUnits().snapshotIterator(); units.hasNext(); ) {
        Stmt unit=(Stmt)units.next();
        for (Iterator boxes=unit.getUseAndDefBoxes().iterator(); boxes.hasNext(); ) {
          ValueBox box=(ValueBox)boxes.next();
          Value value=box.getValue();
          Type type=value.getType();
          if (_isRemovableType(type)) {
            body.getUnits().remove(unit);
            break;
          }
        }
        for (Iterator locals=body.getLocals().snapshotIterator(); locals.hasNext(); ) {
          Local local=(Local)locals.next();
          Type type=local.getType();
          if (_isRemovableType(type)) {
            body.getLocals().remove(local);
          }
        }
      }
      for (Iterator fields=theClass.getFields().snapshotIterator(); fields.hasNext(); ) {
        SootField field=(SootField)fields.next();
        Type type=field.getType();
        if (_isRemovableType(type)) {
          theClass.getFields().remove(field);
        }
      }
    }
  }
  for (Iterator i=Scene.v().getApplicationClasses().iterator(); i.hasNext(); ) {
    SootClass theClass=(SootClass)i.next();
    for (Iterator interfaces=theClass.getInterfaces().snapshotIterator(); interfaces.hasNext(); ) {
      SootClass theInterface=(SootClass)interfaces.next();
      if (theInterface.equals(PtolemyUtilities.inequalityTermClass)) {
        theClass.getInterfaces().remove(theInterface);
      }
      if (theInterface.equals(PtolemyUtilities.explicitChangeContextClass)) {
        theClass.getInterfaces().remove(theInterface);
      }
    }
  }
}