Program: 75514
Project: 75514
Buggy source:
public boolean _inlineTokenMethodsIn(SootMethod method,JimpleBody body,Unit unit,ValueBox box,SimpleLocalDefs localDefs,SimpleLocalUses localUses,TypeSpecializerAnalysis typeAnalysis,int depth,Set unsafeLocalSet,boolean debug){
  Hierarchy hierarchy=Scene.v().getActiveHierarchy();
  boolean doneSomething=false;
  Value value=box.getValue();
  if (value instanceof InvokeExpr) {
    InvokeExpr r=(InvokeExpr)value;
    if (unit instanceof AssignStmt && r.getMethod().getName().equals("String_Node_Str")) {
      AssignStmt stmt=(AssignStmt)unit;
      unsafeLocalSet.add(stmt.getLeftOp());
      unsafeLocalSet.addAll(_computeTokenLocalsDefinedFrom(localUses,stmt));
      if (debug)       System.out.println("String_Node_Str" + unsafeLocalSet);
    }
  }
  if (value instanceof VirtualInvokeExpr || value instanceof InterfaceInvokeExpr || value instanceof SpecialInvokeExpr) {
    InstanceInvokeExpr r=(InstanceInvokeExpr)value;
    Local local=(Local)r.getBase();
    Type baseType=local.getType();
    if (baseType instanceof NullType) {
      if (debug) {
        System.out.println("String_Node_Str" + "String_Node_Str");
      }
      Local exception=SootUtilities.createRuntimeException(body,unit,"String_Node_Str");
      body.getUnits().insertBefore(Jimple.v().newThrowStmt(exception),unit);
      body.getUnits().remove(unit);
    }
    boolean isInlineableTokenMethod=false;
    isInlineableTokenMethod=_isInlineableTokenType(local,typeAnalysis,unsafeLocalSet,depth,debug);
    if (baseType instanceof RefType && Scene.v().getApplicationClasses().contains(((RefType)baseType).getSootClass())) {
      for (Iterator args=r.getArgs().iterator(); args.hasNext() && !isInlineableTokenMethod; ) {
        Object arg=args.next();
        if (arg instanceof Local) {
          Local argLocal=(Local)arg;
          if (debug)           System.out.println("String_Node_Str" + argLocal.getType());
          isInlineableTokenMethod=_isInlineableTokenType(argLocal,typeAnalysis,unsafeLocalSet,depth,debug);
          if (debug) {
            System.out.println("String_Node_Str" + isInlineableTokenMethod);
          }
        }
      }
    }
    if (!isInlineableTokenMethod) {
      return false;
    }
    RefType type=(RefType)typeAnalysis.getSpecializedSootType(local);
    List methodList;
    if (value instanceof SpecialInvokeExpr) {
      SootMethod invokedMethod=hierarchy.resolveSpecialDispatch((SpecialInvokeExpr)r,method);
      methodList=new LinkedList();
      methodList.add(invokedMethod);
    }
 else {
      methodList=hierarchy.resolveAbstractDispatch(type.getSootClass(),r.getMethod());
    }
    if (methodList.size() == 1) {
      SootMethod inlinee=(SootMethod)methodList.get(0);
      if (inlinee.getName().equals("String_Node_Str")) {
        SootMethod newGetClassMethod=Scene.v().getMethod("String_Node_Str" + "String_Node_Str");
        box.setValue(Jimple.v().newStaticInvokeExpr(newGetClassMethod,StringConstant.v("String_Node_Str")));
      }
 else {
        SootClass declaringClass=inlinee.getDeclaringClass();
        declaringClass.setLibraryClass();
        if (!inlinee.isAbstract() && !inlinee.isNative()) {
          if (debug)           System.out.println("String_Node_Str" + inlinee);
          inlinee.retrieveActiveBody();
          SiteInliner.inlineSite(inlinee,(Stmt)unit,method);
          doneSomething=true;
        }
 else {
          throw new RuntimeException("String_Node_Str" + inlinee);
        }
      }
    }
 else {
      if (debug) {
        System.out.println("String_Node_Str" + r);
        for (Iterator j=methodList.iterator(); j.hasNext(); ) {
          System.out.println("String_Node_Str" + j.next());
        }
      }
    }
  }
 else   if (value instanceof SpecialInvokeExpr) {
    SpecialInvokeExpr r=(SpecialInvokeExpr)value;
    if (debug)     System.out.println("String_Node_Str" + r.getMethod());
    Type baseType=typeAnalysis.getSpecializedSootType((Local)r.getBase());
    if (baseType instanceof RefType) {
      RefType type=(RefType)baseType;
      boolean isInlineableTokenMethod=SootUtilities.derivesFrom(type.getSootClass(),PtolemyUtilities.tokenClass);
      if (isInlineableTokenMethod) {
        type=(RefType)typeAnalysis.getSpecializedSootType((Local)r.getBase());
        if (PtolemyUtilities.getTypeDepth(typeAnalysis.getSpecializedType((Local)r.getBase())) != depth) {
          if (debug)           System.out.println("String_Node_Str" + PtolemyUtilities.getTypeDepth(typeAnalysis.getSpecializedType((Local)r.getBase())) + "String_Node_Str"+ depth);
          return false;
        }
      }
      if (isInlineableTokenMethod) {
        SootMethod inlinee=hierarchy.resolveSpecialDispatch(r,method);
        SootClass declaringClass=inlinee.getDeclaringClass();
        declaringClass.setLibraryClass();
        if (!inlinee.isAbstract() && !inlinee.isNative()) {
          if (debug)           System.out.println("String_Node_Str");
          inlinee.retrieveActiveBody();
          SiteInliner.inlineSite(inlinee,(Stmt)unit,method);
          doneSomething=true;
        }
 else {
          if (debug)           System.out.println("String_Node_Str");
          body.getUnits().remove(unit);
        }
      }
    }
  }
 else   if (value instanceof StaticInvokeExpr) {
    StaticInvokeExpr r=(StaticInvokeExpr)value;
    if (r.getMethod().getDeclaringClass().equals(PtolemyUtilities.typeLatticeClass)) {
      try {
        if (debug) {
          System.out.println("String_Node_Str" + unit);
        }
        typeAnalysis.inlineTypeLatticeMethods(method,unit,box,r,localDefs,localUses);
      }
 catch (      Exception ex) {
        System.out.println("String_Node_Str" + ex.getMessage());
      }
    }
 else {
      if (debug) {
        System.out.println("String_Node_Str" + r.getMethod());
      }
      SootMethod inlinee=(SootMethod)r.getMethod();
      SootClass declaringClass=inlinee.getDeclaringClass();
      if (_mangleExceptionMessages && (inlinee.getName().equals("String_Node_Str") || inlinee.getName().equals("String_Node_Str") || inlinee.getName().equals("String_Node_Str")|| inlinee.getName().equals("String_Node_Str"))) {
        box.setValue(StringConstant.v("String_Node_Str"));
      }
 else       if (SootUtilities.derivesFrom(declaringClass,PtolemyUtilities.tokenClass)) {
        declaringClass.setLibraryClass();
        if (!inlinee.isAbstract() && !inlinee.isNative()) {
          if (debug)           System.out.println("String_Node_Str");
          inlinee.retrieveActiveBody();
          SiteInliner.inlineSite(inlinee,(Stmt)unit,method);
          doneSomething=true;
        }
      }
    }
  }
  return doneSomething;
}

Fixed version (ground truth):
public boolean _inlineTokenMethodsIn(SootMethod method,JimpleBody body,Unit unit,ValueBox box,SimpleLocalDefs localDefs,SimpleLocalUses localUses,TypeSpecializerAnalysis typeAnalysis,int depth,Set unsafeLocalSet,boolean debug){
  Hierarchy hierarchy=Scene.v().getActiveHierarchy();
  boolean doneSomething=false;
  Value value=box.getValue();
  if (value instanceof InvokeExpr) {
    InvokeExpr r=(InvokeExpr)value;
    if (unit instanceof AssignStmt && r.getMethod().getName().equals("String_Node_Str")) {
      AssignStmt stmt=(AssignStmt)unit;
      unsafeLocalSet.add(stmt.getLeftOp());
      unsafeLocalSet.addAll(_computeTokenLocalsDefinedFrom(localUses,stmt));
      if (debug)       System.out.println("String_Node_Str" + unsafeLocalSet);
    }
  }
  if (value instanceof VirtualInvokeExpr || value instanceof InterfaceInvokeExpr || value instanceof SpecialInvokeExpr) {
    InstanceInvokeExpr r=(InstanceInvokeExpr)value;
    Local local=(Local)r.getBase();
    Type baseType=local.getType();
    if (baseType instanceof NullType) {
      if (debug) {
        System.out.println("String_Node_Str" + "String_Node_Str");
      }
      Local exception=SootUtilities.createRuntimeException(body,unit,"String_Node_Str");
      body.getUnits().insertBefore(Jimple.v().newThrowStmt(exception),unit);
      body.getUnits().remove(unit);
    }
    boolean isInlineableTokenMethod=false;
    isInlineableTokenMethod=_isInlineableTokenType(local,typeAnalysis,unsafeLocalSet,depth,debug);
    if (baseType instanceof RefType && Scene.v().getApplicationClasses().contains(((RefType)baseType).getSootClass())) {
      for (Iterator args=r.getArgs().iterator(); args.hasNext() && !isInlineableTokenMethod; ) {
        Object arg=args.next();
        if (arg instanceof Local) {
          Local argLocal=(Local)arg;
          if (debug)           System.out.println("String_Node_Str" + argLocal.getType());
          isInlineableTokenMethod=_isInlineableTokenType(argLocal,typeAnalysis,unsafeLocalSet,depth,debug);
          if (debug) {
            System.out.println("String_Node_Str" + isInlineableTokenMethod);
          }
        }
      }
    }
    if (!isInlineableTokenMethod) {
      return false;
    }
    RefType type=(RefType)typeAnalysis.getSpecializedSootType(local);
    List methodList;
    if (value instanceof SpecialInvokeExpr) {
      SootMethod targetMethod=hierarchy.resolveSpecialDispatch((SpecialInvokeExpr)r,method);
      methodList=new LinkedList();
      methodList.add(targetMethod);
    }
 else {
      methodList=hierarchy.resolveAbstractDispatch(type.getSootClass(),r.getMethod());
    }
    if (methodList.size() == 1) {
      SootMethod inlinee=(SootMethod)methodList.get(0);
      if (inlinee.getName().equals("String_Node_Str")) {
        SootMethod newGetClassMethod=Scene.v().getMethod("String_Node_Str" + "String_Node_Str");
        box.setValue(Jimple.v().newStaticInvokeExpr(newGetClassMethod,StringConstant.v("String_Node_Str")));
      }
 else {
        SootClass declaringClass=inlinee.getDeclaringClass();
        declaringClass.setLibraryClass();
        if (!inlinee.isAbstract() && !inlinee.isNative()) {
          if (debug)           System.out.println("String_Node_Str" + inlinee);
          inlinee.retrieveActiveBody();
          SiteInliner.inlineSite(inlinee,(Stmt)unit,method);
          doneSomething=true;
        }
 else {
          throw new RuntimeException("String_Node_Str" + inlinee);
        }
      }
    }
 else {
      if (debug) {
        System.out.println("String_Node_Str" + r);
        for (Iterator j=methodList.iterator(); j.hasNext(); ) {
          System.out.println("String_Node_Str" + j.next());
        }
      }
    }
  }
 else   if (value instanceof SpecialInvokeExpr) {
    SpecialInvokeExpr r=(SpecialInvokeExpr)value;
    if (debug)     System.out.println("String_Node_Str" + r.getMethod());
    Type baseType=typeAnalysis.getSpecializedSootType((Local)r.getBase());
    if (baseType instanceof RefType) {
      RefType type=(RefType)baseType;
      boolean isInlineableTokenMethod=SootUtilities.derivesFrom(type.getSootClass(),PtolemyUtilities.tokenClass);
      if (isInlineableTokenMethod) {
        type=(RefType)typeAnalysis.getSpecializedSootType((Local)r.getBase());
        if (PtolemyUtilities.getTypeDepth(typeAnalysis.getSpecializedType((Local)r.getBase())) != depth) {
          if (debug)           System.out.println("String_Node_Str" + PtolemyUtilities.getTypeDepth(typeAnalysis.getSpecializedType((Local)r.getBase())) + "String_Node_Str"+ depth);
          return false;
        }
      }
      if (isInlineableTokenMethod) {
        SootMethod inlinee=hierarchy.resolveSpecialDispatch(r,method);
        SootClass declaringClass=inlinee.getDeclaringClass();
        declaringClass.setLibraryClass();
        if (!inlinee.isAbstract() && !inlinee.isNative()) {
          if (debug)           System.out.println("String_Node_Str");
          inlinee.retrieveActiveBody();
          SiteInliner.inlineSite(inlinee,(Stmt)unit,method);
          doneSomething=true;
        }
 else {
          if (debug)           System.out.println("String_Node_Str");
          body.getUnits().remove(unit);
        }
      }
    }
  }
 else   if (value instanceof StaticInvokeExpr) {
    StaticInvokeExpr r=(StaticInvokeExpr)value;
    if (r.getMethod().getDeclaringClass().equals(PtolemyUtilities.typeLatticeClass)) {
      try {
        if (debug) {
          System.out.println("String_Node_Str" + unit);
        }
        typeAnalysis.inlineTypeLatticeMethods(method,unit,box,r,localDefs,localUses);
      }
 catch (      Exception ex) {
        System.out.println("String_Node_Str" + ex.getMessage());
      }
    }
 else {
      if (debug) {
        System.out.println("String_Node_Str" + r.getMethod());
      }
      SootMethod inlinee=(SootMethod)r.getMethod();
      SootClass declaringClass=inlinee.getDeclaringClass();
      Type returnType=inlinee.getReturnType();
      if (_mangleExceptionMessages && (inlinee.getName().equals("String_Node_Str") || inlinee.getName().equals("String_Node_Str") || inlinee.getName().equals("String_Node_Str")|| inlinee.getName().equals("String_Node_Str"))) {
        box.setValue(StringConstant.v("String_Node_Str"));
      }
 else       if (SootUtilities.derivesFrom(declaringClass,PtolemyUtilities.tokenClass) || ((returnType instanceof RefType) && SootUtilities.derivesFrom(((RefType)returnType).getSootClass(),PtolemyUtilities.tokenClass))) {
        declaringClass.setLibraryClass();
        if (!inlinee.isAbstract() && !inlinee.isNative()) {
          if (debug)           System.out.println("String_Node_Str");
          inlinee.retrieveActiveBody();
          SiteInliner.inlineSite(inlinee,(Stmt)unit,method);
          doneSomething=true;
        }
      }
    }
  }
  return doneSomething;
}