Program: 88549
Project: 88549
Buggy source:
private ArrayList addFinalLocals(polyglot.ast.ClassBody cBody,ArrayList finalLocalsAvail,polyglot.types.ClassType nodeKeyType,AnonLocalClassInfo info){
  ArrayList finalFields=new ArrayList();
  LocalUsesChecker luc=new LocalUsesChecker();
  cBody.visit(luc);
  Iterator localsNeededIt=luc.getLocals().iterator();
  ArrayList localsUsed=new ArrayList();
  while (localsNeededIt.hasNext()) {
    polyglot.types.LocalInstance li=(polyglot.types.LocalInstance)((polyglot.util.IdentityKey)localsNeededIt.next()).object();
    if (finalLocalsAvail.contains(new polyglot.util.IdentityKey(li)) && !luc.getLocalDecls().contains(new polyglot.util.IdentityKey(li))) {
      addFinals(li,finalFields);
      localsUsed.add(new polyglot.util.IdentityKey(li));
    }
  }
  Iterator newsIt=luc.getNews().iterator();
  while (newsIt.hasNext()) {
    polyglot.ast.New tempNew=(polyglot.ast.New)newsIt.next();
    polyglot.types.ClassType tempNewType=(polyglot.types.ClassType)tempNew.objectType().type();
    if (InitialResolver.v().finalLocalInfo().containsKey(new polyglot.util.IdentityKey(tempNewType))) {
      AnonLocalClassInfo lInfo=(AnonLocalClassInfo)InitialResolver.v().finalLocalInfo().get(new polyglot.util.IdentityKey(tempNewType));
      Iterator it=lInfo.finalLocalsAvail().iterator();
      while (it.hasNext()) {
        polyglot.types.LocalInstance li2=(polyglot.types.LocalInstance)((polyglot.util.IdentityKey)it.next()).object();
        if (!sootClass.declaresField("String_Node_Str" + li2.name(),Util.getSootType(li2.type()))) {
          if (!luc.getLocalDecls().contains(new polyglot.util.IdentityKey(li2))) {
            addFinals(li2,finalFields);
            localsUsed.add(new polyglot.util.IdentityKey(li2));
          }
        }
      }
    }
  }
  info.finalLocalsUsed(localsUsed);
  InitialResolver.v().finalLocalInfo().put(new polyglot.util.IdentityKey(nodeKeyType),info);
  return finalFields;
}

Fixed version (ground truth):
private ArrayList addFinalLocals(polyglot.ast.ClassBody cBody,ArrayList finalLocalsAvail,polyglot.types.ClassType nodeKeyType,AnonLocalClassInfo info){
  ArrayList finalFields=new ArrayList();
  LocalUsesChecker luc=new LocalUsesChecker();
  cBody.visit(luc);
  ArrayList localsUsed=new ArrayList();
  Iterator fieldsNeededIt=finalLocalsAvail.iterator();
  while (fieldsNeededIt.hasNext()) {
    polyglot.types.LocalInstance li=(polyglot.types.LocalInstance)((polyglot.util.IdentityKey)fieldsNeededIt.next()).object();
    if (!luc.getLocalDecls().contains(new polyglot.util.IdentityKey(li))) {
      localsUsed.add(new polyglot.util.IdentityKey(li));
      addFinals(li,finalFields);
    }
  }
  Iterator newsIt=luc.getNews().iterator();
  while (newsIt.hasNext()) {
    polyglot.ast.New tempNew=(polyglot.ast.New)newsIt.next();
    polyglot.types.ClassType tempNewType=(polyglot.types.ClassType)tempNew.objectType().type();
    if (InitialResolver.v().finalLocalInfo().containsKey(new polyglot.util.IdentityKey(tempNewType))) {
      AnonLocalClassInfo lInfo=(AnonLocalClassInfo)InitialResolver.v().finalLocalInfo().get(new polyglot.util.IdentityKey(tempNewType));
      Iterator it=lInfo.finalLocalsAvail().iterator();
      while (it.hasNext()) {
        polyglot.types.LocalInstance li2=(polyglot.types.LocalInstance)((polyglot.util.IdentityKey)it.next()).object();
        if (!sootClass.declaresField("String_Node_Str" + li2.name(),Util.getSootType(li2.type()))) {
          if (!luc.getLocalDecls().contains(new polyglot.util.IdentityKey(li2))) {
            addFinals(li2,finalFields);
            localsUsed.add(new polyglot.util.IdentityKey(li2));
          }
        }
      }
    }
  }
  polyglot.types.ClassType superType=(polyglot.types.ClassType)nodeKeyType.superType();
  while (!Util.getSootType(superType).equals(soot.Scene.v().getSootClass("String_Node_Str").getType())) {
    if (InitialResolver.v().finalLocalInfo().containsKey(new polyglot.util.IdentityKey(superType))) {
      AnonLocalClassInfo lInfo=(AnonLocalClassInfo)InitialResolver.v().finalLocalInfo().get(new polyglot.util.IdentityKey(superType));
      Iterator it=lInfo.finalLocalsAvail().iterator();
      while (it.hasNext()) {
        polyglot.types.LocalInstance li2=(polyglot.types.LocalInstance)((polyglot.util.IdentityKey)it.next()).object();
        if (!sootClass.declaresField("String_Node_Str" + li2.name(),Util.getSootType(li2.type()))) {
          if (!luc.getLocalDecls().contains(new polyglot.util.IdentityKey(li2))) {
            addFinals(li2,finalFields);
            localsUsed.add(new polyglot.util.IdentityKey(li2));
          }
        }
      }
    }
    superType=(polyglot.types.ClassType)superType.superType();
  }
  info.finalLocalsUsed(localsUsed);
  InitialResolver.v().finalLocalInfo().put(new polyglot.util.IdentityKey(nodeKeyType),info);
  return finalFields;
}