nus-yam/ex-repair huggingface dataset:
Program: 146854
Project: 146854
Buggy source:
/** 
 * Get text for locale and exact text ID only, not using any fallbacks. NOTE: This call will only return the full compliment of available strings if and  only if the requested locale is current. Otherwise it will only retrieve strings declared at runtime.
 * @param locale Locale. Must be defined and not null.
 * @param textID Text handle (text ID appended with optional text form). Must not be null.
 * @return Localized text. Return null if none found.
 * @throws UnregisteredLocaleException If the locale is not defined or null.
 * @throws NullPointerException if textID is null
 */
public String getRawText(String locale,String textID){
  if (locale == null) {
    throw new UnregisteredLocaleException("String_Node_Str" + textID);
  }
  if (locale.equals(currentLocale)) {
    return currentLocaleData.get(textID).render();
  }
 else {
    return (String)getLocaleMap(locale).get(textID);
  }
}

Fixed version (ground truth):
/** 
 * Get text for locale and exact text ID only, not using any fallbacks. NOTE: This call will only return the full compliment of available strings if and  only if the requested locale is current. Otherwise it will only retrieve strings declared at runtime.
 * @param locale Locale. Must be defined and not null.
 * @param textID Text handle (text ID appended with optional text form). Must not be null.
 * @return Localized text. Return null if none found.
 * @throws UnregisteredLocaleException If the locale is not defined or null.
 * @throws NullPointerException if textID is null
 */
public String getRawText(String locale,String textID){
  if (locale == null) {
    throw new UnregisteredLocaleException("String_Node_Str" + textID);
  }
  if (locale.equals(currentLocale)) {
    PrefixTreeNode data=currentLocaleData.get(textID);
    return data == null ? null : data.render();
  }
 else {
    return (String)getLocaleMap(locale).get(textID);
  }
}
Program: 146855
Project: 146855
Buggy source:
public void writeExternal(DataOutputStream out) throws IOException {
  ExtUtil.writeString(out,ExtUtil.emptyIfNull(name));
  ExtUtil.writeNumeric(out,multiplicity);
  ExtUtil.write(out,new ExtWrapList(ExtUtil.emptyIfNull(predicates)));
}

Fixed version (ground truth):
public void writeExternal(DataOutputStream out) throws IOException {
  ExtUtil.writeString(out,ExtUtil.emptyIfNull(name));
  ExtUtil.writeNumeric(out,multiplicity);
  ExtUtil.write(out,new ExtWrapListPoly(ExtUtil.emptyIfNull(predicates)));
}
Program: 146856
Project: 146856
Buggy source:
public void readExternal(DataInputStream in,PrototypeFactory pf) throws IOException, DeserializationException {
  name=ExtUtil.nullIfEmpty(ExtUtil.readString(in));
  multiplicity=ExtUtil.readInt(in);
  predicates=ExtUtil.nullIfEmpty((Vector<XPathExpression>)ExtUtil.read(in,new ExtWrapList(new ExtWrapTagged())));
}

Fixed version (ground truth):
public void readExternal(DataInputStream in,PrototypeFactory pf) throws IOException, DeserializationException {
  name=ExtUtil.nullIfEmpty(ExtUtil.readString(in));
  multiplicity=ExtUtil.readInt(in);
  predicates=ExtUtil.nullIfEmpty((Vector<XPathExpression>)ExtUtil.read(in,new ExtWrapListPoly()));
}
Program: 146858
Project: 146858
Buggy source:
public void triggerTriggerables(TreeReference ref){
  TreeReference genericRef=ref.genericize();
  Vector triggered=(Vector)triggerIndex.get(genericRef);
  if (triggered == null)   return;
  Vector triggeredCopy=new Vector();
  for (int i=0; i < triggered.size(); i++)   triggeredCopy.addElement(triggered.elementAt(i));
  evaluateTriggerables(triggeredCopy,ref);
}

Fixed version (ground truth):
public void triggerTriggerables(TreeReference ref){
  TreeReference genericRef=ref.genericize();
  Vector triggered=(Vector)triggerIndex.get(genericRef);
  if (triggered == null) {
    return;
  }
  Vector triggeredCopy=new Vector();
  for (int i=0; i < triggered.size(); i++) {
    triggeredCopy.addElement(triggered.elementAt(i));
  }
  evaluateTriggerables(triggeredCopy,ref);
}
Program: 146860
Project: 146860
Buggy source:
/** 
 * Add a Condition to the form's Collection.
 * @param condition the condition to be set
 */
public Triggerable addTriggerable(Triggerable t){
  int existingIx=triggerables.indexOf(t);
  if (existingIx >= 0) {
    Triggerable existingTriggerable=(Triggerable)triggerables.elementAt(existingIx);
    existingTriggerable.contextRef=existingTriggerable.contextRef.intersect(t.contextRef);
    return existingTriggerable;
  }
 else {
    triggerables.addElement(t);
    triggerablesInOrder=false;
    Vector triggers=t.getTriggers();
    for (int i=0; i < triggers.size(); i++) {
      TreeReference trigger=(TreeReference)triggers.elementAt(i);
      if (!triggerIndex.containsKey(trigger)) {
        triggerIndex.put(trigger,new Vector());
      }
      Vector triggered=(Vector)triggerIndex.get(trigger);
      if (!triggered.contains(t)) {
        triggered.addElement(t);
      }
    }
    return t;
  }
}

Fixed version (ground truth):
/** 
 * Add a Condition to the form's Collection.
 * @param condition the condition to be set
 */
public Triggerable addTriggerable(Triggerable t){
  int existingIx=triggerables.indexOf(t);
  if (existingIx >= 0) {
    Triggerable existingTriggerable=(Triggerable)triggerables.elementAt(existingIx);
    existingTriggerable.contextRef=existingTriggerable.contextRef.intersect(t.contextRef);
    return existingTriggerable;
  }
 else {
    triggerables.addElement(t);
    triggerablesInOrder=false;
    Vector triggers=t.getTriggers();
    for (int i=0; i < triggers.size(); i++) {
      TreeReference trigger=(TreeReference)triggers.elementAt(i);
      if (!triggerIndex.containsKey(trigger)) {
        triggerIndex.put(trigger.clone(),new Vector());
      }
      Vector triggered=(Vector)triggerIndex.get(trigger);
      if (!triggered.contains(t)) {
        triggered.addElement(t);
      }
    }
    return t;
  }
}
Program: 146861
Project: 146861
Buggy source:
private void evaluateTriggerable(Triggerable t,TreeReference anchorRef){
  TreeReference contextRef=t.contextRef.contextualize(anchorRef);
  Vector v=exprEvalContext.expandReference(contextRef);
  for (int i=0; i < v.size(); i++) {
    EvaluationContext ec=new EvaluationContext(exprEvalContext,(TreeReference)v.elementAt(i));
    try {
      t.apply(mainInstance,ec,this);
    }
 catch (    RuntimeException e) {
      throw e;
    }
  }
}

Fixed version (ground truth):
private void evaluateTriggerable(Triggerable t,TreeReference anchorRef){
  TreeReference contextRef=t.contextRef.contextualize(anchorRef);
  Vector<TreeReference> v=exprEvalContext.expandReference(contextRef);
  for (int i=0; i < v.size(); i++) {
    try {
      t.apply(mainInstance,exprEvalContext,v.elementAt(i),this);
    }
 catch (    RuntimeException e) {
      throw e;
    }
  }
}
Program: 146862
Project: 146862
Buggy source:
Vector getTriggers();

Fixed version (ground truth):
Vector<TreeReference> getTriggers();
Program: 146863
Project: 146863
Buggy source:
Vector evalNodeset(DataInstance model,EvaluationContext evalContext);

Fixed version (ground truth):
Vector<TreeReference> evalNodeset(DataInstance model,EvaluationContext evalContext);
Program: 146864
Project: 146864
Buggy source:
public Vector getTargets(){
  return targets;
}

Fixed version (ground truth):
public Vector<TreeReference> getTargets(){
  return targets;
}
Program: 146865
Project: 146865
Buggy source:
public Vector getTriggers(){
  Vector relTriggers=expr.getTriggers();
  Vector absTriggers=new Vector();
  for (int i=0; i < relTriggers.size(); i++) {
    absTriggers.addElement(((TreeReference)relTriggers.elementAt(i)).anchor(contextRef));
  }
  return absTriggers;
}

Fixed version (ground truth):
public Vector<TreeReference> getTriggers(){
  Vector<TreeReference> relTriggers=expr.getTriggers();
  Vector<TreeReference> absTriggers=new Vector<TreeReference>();
  for (int i=0; i < relTriggers.size(); i++) {
    absTriggers.addElement(((TreeReference)relTriggers.elementAt(i)).anchor(originalContextRef));
  }
  return absTriggers;
}
Program: 146866
Project: 146866
Buggy source:
public void writeExternal(DataOutputStream out) throws IOException {
  ExtUtil.write(out,new ExtWrapTagged(expr));
  ExtUtil.write(out,contextRef);
  ExtUtil.write(out,new ExtWrapList(targets));
}

Fixed version (ground truth):
public void writeExternal(DataOutputStream out) throws IOException {
  ExtUtil.write(out,new ExtWrapTagged(expr));
  ExtUtil.write(out,contextRef);
  ExtUtil.write(out,originalContextRef);
  ExtUtil.write(out,new ExtWrapList(targets));
}
Program: 146867
Project: 146867
Buggy source:
public void apply(FormInstance instance,EvaluationContext evalContext,FormDef f){
  Object result=eval(instance,evalContext);
  for (int i=0; i < targets.size(); i++) {
    TreeReference targetRef=((TreeReference)targets.elementAt(i)).contextualize(evalContext.getContextRef());
    Vector v=evalContext.expandReference(targetRef);
    for (int j=0; j < v.size(); j++) {
      TreeReference affectedRef=(TreeReference)v.elementAt(j);
      apply(affectedRef,result,instance,f);
    }
  }
}

Fixed version (ground truth):
/** 
 * Not for re-implementation, dispatches all of the evaluation 
 * @param instance
 * @param evalContext
 * @param f
 */
public final void apply(FormInstance instance,EvaluationContext parentContext,TreeReference context,FormDef f){
  TreeReference ungenericised=originalContextRef.contextualize(context);
  EvaluationContext ec=new EvaluationContext(parentContext,ungenericised);
  Object result=eval(instance,ec);
  for (int i=0; i < targets.size(); i++) {
    TreeReference targetRef=((TreeReference)targets.elementAt(i)).contextualize(ec.getContextRef());
    Vector v=ec.expandReference(targetRef);
    for (int j=0; j < v.size(); j++) {
      TreeReference affectedRef=(TreeReference)v.elementAt(j);
      apply(affectedRef,result,instance,f);
    }
  }
}
Program: 146868
Project: 146868
Buggy source:
public boolean equals(Object o){
  if (o instanceof Triggerable) {
    Triggerable t=(Triggerable)o;
    if (this == t)     return true;
    if (this.expr.equals(t.expr)) {
      Vector Atriggers=this.getTriggers();
      Vector Btriggers=t.getTriggers();
      for (int k=0; k < 2; k++) {
        Vector v1=(k == 0 ? Atriggers : Btriggers);
        Vector v2=(k == 0 ? Btriggers : Atriggers);
        for (int i=0; i < v1.size(); i++) {
          if (v2.indexOf(v1.elementAt(i)) == -1) {
            return false;
          }
        }
      }
      return true;
    }
 else {
      return false;
    }
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
public boolean equals(Object o){
  if (o instanceof Triggerable) {
    Triggerable t=(Triggerable)o;
    if (this == t)     return true;
    if (this.expr.equals(t.expr)) {
      Vector<TreeReference> Atriggers=this.getTriggers();
      Vector<TreeReference> Btriggers=t.getTriggers();
      for (int k=0; k < 2; k++) {
        Vector<TreeReference> v1=(k == 0 ? Atriggers : Btriggers);
        Vector<TreeReference> v2=(k == 0 ? Btriggers : Atriggers);
        for (int i=0; i < v1.size(); i++) {
          if (!v1.elementAt(i).isAbsolute() || v2.indexOf(v1.elementAt(i)) == -1) {
            return false;
          }
        }
      }
      return true;
    }
 else {
      return false;
    }
  }
 else {
    return false;
  }
}
Program: 146869
Project: 146869
Buggy source:
public void readExternal(DataInputStream in,PrototypeFactory pf) throws IOException, DeserializationException {
  expr=(IConditionExpr)ExtUtil.read(in,new ExtWrapTagged(),pf);
  contextRef=(TreeReference)ExtUtil.read(in,TreeReference.class,pf);
  targets=(Vector)ExtUtil.read(in,new ExtWrapList(TreeReference.class),pf);
}

Fixed version (ground truth):
public void readExternal(DataInputStream in,PrototypeFactory pf) throws IOException, DeserializationException {
  expr=(IConditionExpr)ExtUtil.read(in,new ExtWrapTagged(),pf);
  contextRef=(TreeReference)ExtUtil.read(in,TreeReference.class,pf);
  originalContextRef=(TreeReference)ExtUtil.read(in,TreeReference.class,pf);
  targets=(Vector<TreeReference>)ExtUtil.read(in,new ExtWrapList(TreeReference.class),pf);
}
Program: 146870
Project: 146870
Buggy source:
public Triggerable(IConditionExpr expr,TreeReference contextRef){
  this.expr=expr;
  this.contextRef=contextRef;
  this.targets=new Vector();
}

Fixed version (ground truth):
public Triggerable(IConditionExpr expr,TreeReference contextRef){
  this.expr=expr;
  this.contextRef=contextRef;
  this.originalContextRef=contextRef;
  this.targets=new Vector();
}
Program: 146871
Project: 146871
Buggy source:
private static void getTriggers(XPathExpression x,Vector v,TreeReference contextRef){
  if (x instanceof XPathPathExpr) {
    TreeReference ref=((XPathPathExpr)x).getReference();
    TreeReference contextualized=ref;
    if (contextRef != null) {
      contextualized=ref.contextualize(contextRef);
    }
    if (!v.contains(contextualized)) {
      v.addElement(contextualized);
    }
    for (int i=0; i < ref.size(); i++) {
      Vector<XPathExpression> predicates=ref.getPredicate(i);
      if (predicates == null) {
        continue;
      }
      if (!ref.isAbsolute()) {
        throw new IllegalArgumentException("String_Node_Str");
      }
      TreeReference predicateContext=ref.getSubReference(i);
      for (      XPathExpression predicate : predicates) {
        getTriggers(predicate,v,predicateContext);
      }
    }
  }
 else   if (x instanceof XPathBinaryOpExpr) {
    getTriggers(((XPathBinaryOpExpr)x).a,v,contextRef);
    getTriggers(((XPathBinaryOpExpr)x).b,v,contextRef);
  }
 else   if (x instanceof XPathUnaryOpExpr) {
    getTriggers(((XPathUnaryOpExpr)x).a,v,contextRef);
  }
 else   if (x instanceof XPathFuncExpr) {
    XPathFuncExpr fx=(XPathFuncExpr)x;
    for (int i=0; i < fx.args.length; i++)     getTriggers(fx.args[i],v,contextRef);
  }
}

Fixed version (ground truth):
private static void getTriggers(XPathExpression x,Vector<TreeReference> v,TreeReference contextRef){
  if (x instanceof XPathPathExpr) {
    TreeReference ref=((XPathPathExpr)x).getReference();
    TreeReference contextualized=ref;
    if (contextRef != null) {
      contextualized=ref.contextualize(contextRef);
    }
    if (!v.contains(contextualized)) {
      v.addElement(contextualized);
    }
    for (int i=0; i < ref.size(); i++) {
      Vector<XPathExpression> predicates=ref.getPredicate(i);
      if (predicates == null) {
        continue;
      }
      if (!ref.isAbsolute()) {
        throw new IllegalArgumentException("String_Node_Str");
      }
      TreeReference predicateContext=ref.getSubReference(i);
      for (      XPathExpression predicate : predicates) {
        getTriggers(predicate,v,predicateContext);
      }
    }
  }
 else   if (x instanceof XPathBinaryOpExpr) {
    getTriggers(((XPathBinaryOpExpr)x).a,v,contextRef);
    getTriggers(((XPathBinaryOpExpr)x).b,v,contextRef);
  }
 else   if (x instanceof XPathUnaryOpExpr) {
    getTriggers(((XPathUnaryOpExpr)x).a,v,contextRef);
  }
 else   if (x instanceof XPathFuncExpr) {
    XPathFuncExpr fx=(XPathFuncExpr)x;
    for (int i=0; i < fx.args.length; i++)     getTriggers(fx.args[i],v,contextRef);
  }
}
Program: 146872
Project: 146872
Buggy source:
public String[] getSortFieldNames(){
  Vector<String> fields=new Vector<String>();
  int sortField=this.getSortFieldDefault() - 1;
  String[] headers=getHeaders(false);
  if (sortField == -1) {
    fields.addElement(Localization.get("String_Node_Str"));
  }
 else {
    fields.addElement(headers[sortField]);
    fields.addElement(Localization.get("String_Node_Str"));
  }
  for (int i=0; i < headers.length; ++i) {
    if (i == sortField) {
      continue;
    }
    String s=headers[i];
    if (s == null || "String_Node_Str".equals(s)) {
      continue;
    }
    fields.addElement(s);
  }
  String[] ret=new String[fields.size()];
  for (int i=0; i < ret.length; ++i) {
    ret[i]=fields.elementAt(i);
  }
  return ret;
}

Fixed version (ground truth):
public String[] getSortFieldNames(){
  Vector<String> fields=new Vector<String>();
  int sortField=this.getSortFieldDefault();
  if (sortField != -1) {
    sortField--;
  }
  String[] headers=getHeaders(false);
  if (sortField == -1) {
    fields.addElement(Localization.get("String_Node_Str"));
  }
 else {
    fields.addElement(headers[sortField]);
    fields.addElement(Localization.get("String_Node_Str"));
  }
  for (int i=0; i < headers.length; ++i) {
    if (i == sortField) {
      continue;
    }
    String s=headers[i];
    if (s == null || "String_Node_Str".equals(s)) {
      continue;
    }
    fields.addElement(s);
  }
  String[] ret=new String[fields.size()];
  for (int i=0; i < ret.length; ++i) {
    ret[i]=fields.elementAt(i);
  }
  return ret;
}
Program: 146874
Project: 146874
Buggy source:
protected JrFormEntryController getController(){
  FormDefFetcher fetcher=new FormDefFetcher(new NamespaceRetrievalMethod(formName),preloaders,funcHandlers,iif);
  JrFormEntryController controller=CommCareUtil.createFormEntryController(fetcher);
  controller.setView(loadView(title,controller));
  return controller;
}

Fixed version (ground truth):
protected JrFormEntryController getController(){
  FormDefFetcher fetcher=new FormDefFetcher(new NamespaceRetrievalMethod(formName),preloaders,funcHandlers,iif);
  boolean supportsNewRepeats=false;
  String viewType=PropertyManager._().getSingularProperty(FormManagerProperties.VIEW_TYPE_PROPERTY);
  if (FormManagerProperties.VIEW_CHATTERBOX.equals(viewType)) {
    supportsNewRepeats=true;
  }
  JrFormEntryController controller=CommCareUtil.createFormEntryController(fetcher,supportsNewRepeats);
  controller.setView(loadView(title,controller));
  return controller;
}
Program: 146875
Project: 146875
Buggy source:
private Vector<String> roots(){
  if (fileroots == null) {
    fileroots=new Vector<String>();
    try {
      for (Enumeration en=FileSystemRegistry.listRoots(); en.hasMoreElements(); ) {
        String root=(String)en.nextElement();
        if (root.endsWith("String_Node_Str")) {
          root=root.substring(0,root.length() - 1);
          fileroots.addElement(root);
        }
      }
    }
 catch (    SecurityException e) {
      this.securityException(e);
      if (fileroots.size() > 0) {
        return fileroots;
      }
 else {
        fileroots=null;
        return new Vector<String>();
      }
    }
  }
  return fileroots;
}

Fixed version (ground truth):
private Vector<String> roots(){
  if (fileroots == null) {
    fileroots=new Vector<String>();
    try {
      for (Enumeration en=FileSystemRegistry.listRoots(); en.hasMoreElements(); ) {
        String root=(String)en.nextElement();
        if (root.endsWith("String_Node_Str")) {
          root=root.substring(0,root.length() - 1);
          fileroots.addElement(root);
        }
      }
    }
 catch (    SecurityException e) {
      this.securityException(e);
      if (fileroots.size() > 0) {
        return fileroots;
      }
 else {
        fileroots=null;
        return new Vector<String>();
      }
    }
catch (    NullPointerException npe) {
      return new Vector<String>();
    }
  }
  return fileroots;
}
Program: 146876
Project: 146876
Buggy source:
/** 
 * meant to be called after deserialization and initialization of handlers
 * @param newInstance true if the form is to be used for a new entry interaction, false if it is using an existing IDataModel
 */
public void initialize(boolean newInstance,InstanceInitializationFactory factory){
  for (Enumeration en=formInstances.keys(); en.hasMoreElements(); ) {
    String instanceId=(String)en.nextElement();
    DataInstance instance=formInstances.get(instanceId);
    instance.initialize(factory,instanceId);
  }
  if (newInstance) {
    preloadInstance(mainInstance.getRoot());
  }
  if (getLocalizer() != null && getLocalizer().getLocale() == null) {
    getLocalizer().setToDefault();
  }
  initializeTriggerables();
  dispatchFormEvent(Action.EVENT_XFORMS_READY);
}

Fixed version (ground truth):
/** 
 * meant to be called after deserialization and initialization of handlers
 * @param newInstance true if the form is to be used for a new entry interaction, false if it is using an existing IDataModel
 */
public void initialize(boolean newInstance,InstanceInitializationFactory factory){
  for (Enumeration en=formInstances.keys(); en.hasMoreElements(); ) {
    String instanceId=(String)en.nextElement();
    DataInstance instance=formInstances.get(instanceId);
    instance.initialize(factory,instanceId);
  }
  if (newInstance) {
    preloadInstance(mainInstance.getRoot());
  }
  if (getLocalizer() != null && getLocalizer().getLocale() == null) {
    getLocalizer().setToDefault();
  }
  dispatchFormEvent(Action.EVENT_XFORMS_READY);
  initializeTriggerables();
}
Program: 146878
Project: 146878
Buggy source:
public static Alert showError(String title,String message,Image image,Displayable next,CommandListener customListener){
  final Alert alert=new Alert(title,message,image,AlertType.ERROR){
    int latches=0;
{
      getKeyStates();
    }
    protected boolean handleKeyPressed(    int keyCode,    int gameAction){
      return super.handleKeyPressed(keyCode,gameAction);
    }
    protected boolean handleKeyReleased(    int keyCode,    int gameAction){
      if (this.getKeyStates() > 0) {
        return super.handleKeyReleased(keyCode,gameAction);
      }
      return true;
    }
  }
;
  alert.setTimeout(Alert.FOREVER);
  if (customListener != null) {
    if (next != null) {
      System.err.println("String_Node_Str");
    }
    alert.setCommandListener(customListener);
  }
  if (next == null) {
    setView(alert);
  }
 else {
    loading.cancelLoading();
  }
  return alert;
}

Fixed version (ground truth):
public static Alert showError(String title,String message,Image image,Displayable next,CommandListener customListener){
  final Alert alert=new Alert(title,message,image,AlertType.ERROR){
    int latches=0;
{
      getKeyStates();
    }
    protected boolean handleKeyPressed(    int keyCode,    int gameAction){
      return super.handleKeyPressed(keyCode,gameAction);
    }
    protected boolean handleKeyReleased(    int keyCode,    int gameAction){
      if (this.getKeyStates() > 0) {
        return super.handleKeyReleased(keyCode,gameAction);
      }
      return true;
    }
  }
;
  alert.setTimeout(Alert.FOREVER);
  if (customListener != null) {
    if (next != null) {
      System.err.println("String_Node_Str");
    }
    alert.setCommandListener(customListener);
  }
  if (next == null) {
    setView(alert,true);
  }
 else {
    loading.cancelLoading();
  }
  return alert;
}
Program: 146879
Project: 146879
Buggy source:
public static void setView(Displayable d){
  loading.cancelLoading();
  Displayable old=display.getCurrent();
  display.setCurrent(d);
  if (old instanceof Screen) {
    try {
      old.addCommand(new Command("String_Node_Str",2,2));
      UiAccess.releaseResources((Screen)old);
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
}

Fixed version (ground truth):
/** 
 * Sets the current displayable with the option to either clear or not clear the heavy resources from the current view 
 * @param d The new displayable to be viewed
 * @param savePreviousView false if resources should freed from thecurrent screen. True if those resources should be maintained. NOTE: if the current screen has major resources and True is set, those resources might need to be freed manually if any hanging references depend on them.
 */
public static void setView(Displayable d,boolean savePreviousView){
  loading.cancelLoading();
  Displayable old=display.getCurrent();
  display.setCurrent(d);
  if (!savePreviousView) {
    if (old instanceof Screen) {
      try {
        Command placeholder=new Command("String_Node_Str",2,2);
        old.addCommand(placeholder);
        UiAccess.releaseResources((Screen)old);
        old.removeCommand(placeholder);
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
    }
  }
}
Program: 146881
Project: 146881
Buggy source:
public TreeElementCache(int capacity){
  cache=new Hashtable<Integer,TreeElement>();
  this.capacityDesired=capacity;
  this.currentCapacity=capacityDesired;
  random=new Random();
  cacheList=new Vector<Integer>();
  totalMem=Runtime.getRuntime().freeMemory();
}

Fixed version (ground truth):
public TreeElementCache(int capacity){
  cache=new Hashtable<Integer,TreeElement>();
  this.capacityDesired=capacity;
  this.currentCapacity=capacityDesired;
  random=new Random();
  cacheList=new Vector<Integer>();
  Runtime.getRuntime().gc();
  totalMem=Runtime.getRuntime().freeMemory();
}
Program: 146882
Project: 146882
Buggy source:
public void register(int recordId,TreeElement item){
  long freeMemory=Runtime.getRuntime().freeMemory();
  double memory=freeMemory * 1.0 / totalMem;
  if (memory < .2) {
    Runtime.getRuntime().gc();
    freeMemory=Runtime.getRuntime().freeMemory();
    memory=freeMemory * 1.0 / totalMem;
  }
  if (memory < .2) {
    currentCapacity=Math.max(10,(int)(currentCapacity * .6));
    System.out.println("String_Node_Str" + currentCapacity);
    while (cache.size() > currentCapacity - 1) {
      randomPop();
    }
  }
  if (cache.size() == currentCapacity) {
    if (currentCapacity < capacityDesired && memory > .3) {
      currentCapacity+=(capacityDesired - currentCapacity) * .3;
      System.out.println("String_Node_Str" + currentCapacity);
    }
 else {
      for (int i=0; i < 3; ++i) {
        randomPop();
      }
    }
  }
  cache.put(new Integer(recordId),item);
  cacheList.addElement(new Integer(recordId));
}

Fixed version (ground truth):
public void register(int recordId,TreeElement item){
  long freeMemory=Runtime.getRuntime().freeMemory();
  double memory=freeMemory * 1.0 / totalMem;
  if (memory < .2) {
    Runtime.getRuntime().gc();
    freeMemory=Runtime.getRuntime().freeMemory();
    memory=freeMemory * 1.0 / totalMem;
  }
  if (memory < .2) {
    currentCapacity=Math.max(10,(int)(currentCapacity * .6));
    System.out.println("String_Node_Str" + currentCapacity);
    while (cache.size() > currentCapacity - 1) {
      randomPop();
    }
  }
  if (cache.size() == currentCapacity) {
    if (currentCapacity < capacityDesired && memory > .3) {
      currentCapacity++;
      System.out.println("String_Node_Str" + currentCapacity);
    }
 else {
      for (int i=0; i < 3; ++i) {
        randomPop();
      }
    }
  }
  cache.put(new Integer(recordId),item);
  cacheList.addElement(new Integer(recordId));
}
Program: 146884
Project: 146884
Buggy source:
public int indexOfKey(Object key){
  return orderedKeys.indexOf(key);
}

Fixed version (ground truth):
public int indexOfKey(K key){
  return orderedKeys.indexOf(key);
}
Program: 146885
Project: 146885
Buggy source:
public OrderedHashtable(int initialCapacity){
  super(initialCapacity);
  orderedKeys=new Vector(initialCapacity);
}

Fixed version (ground truth):
public OrderedHashtable(int initialCapacity){
  super(initialCapacity);
  orderedKeys=new Vector<K>(initialCapacity);
}
Program: 146886
Project: 146886
Buggy source:
public Object put(Object key,Object value){
  if (key == null) {
    throw new NullPointerException();
  }
  int i=orderedKeys.indexOf(key);
  if (i == -1) {
    orderedKeys.addElement(key);
  }
 else {
    orderedKeys.setElementAt(key,i);
  }
  return super.put(key,value);
}

Fixed version (ground truth):
public V put(K key,V value){
  if (key == null) {
    throw new NullPointerException();
  }
  int i=orderedKeys.indexOf(key);
  if (i == -1) {
    orderedKeys.addElement(key);
  }
 else {
    orderedKeys.setElementAt(key,i);
  }
  return super.put(key,value);
}
Program: 146887
Project: 146887
Buggy source:
public Object remove(Object key){
  orderedKeys.removeElement(key);
  return super.remove(key);
}

Fixed version (ground truth):
public V remove(Object key){
  orderedKeys.removeElement((K)key);
  return super.remove(key);
}
Program: 146889
Project: 146889
Buggy source:
/** 
 * convert a value to a number using xpath's type conversion rules (note that xpath itself makes no distinction between integer and floating point numbers)
 * @param o
 * @return
 */
public static Double toNumeric(Object o){
  Double val=null;
  o=unpack(o);
  if (o instanceof Boolean) {
    val=new Double(((Boolean)o).booleanValue() ? 1 : 0);
  }
 else   if (o instanceof Double) {
    val=(Double)o;
  }
 else   if (o instanceof String) {
    String s=(String)o;
    double d;
    try {
      s=s.trim();
      for (int i=0; i < s.length(); i++) {
        char c=s.charAt(i);
        if (c != '-' && c != '.' && (c < '0' || c > '9'))         throw new NumberFormatException();
      }
      d=Double.parseDouble(s);
      val=new Double(d);
    }
 catch (    NumberFormatException nfe) {
      val=new Double(Double.NaN);
    }
  }
 else   if (o instanceof Date) {
    val=new Double(DateUtils.daysSinceEpoch((Date)o));
  }
 else   if (o instanceof IExprDataType) {
    val=((IExprDataType)o).toNumeric();
  }
  if (val != null) {
    return val;
  }
 else {
    throw new XPathTypeMismatchException("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * convert a value to a number using xpath's type conversion rules (note that xpath itself makes no distinction between integer and floating point numbers)
 * @param o
 * @return
 */
public static Double toNumeric(Object o){
  Double val=null;
  o=unpack(o);
  if (o instanceof Boolean) {
    val=new Double(((Boolean)o).booleanValue() ? 1 : 0);
  }
 else   if (o instanceof Double) {
    val=(Double)o;
  }
 else   if (o instanceof String) {
    String s=(String)o;
    double d;
    try {
      s=s.trim();
      for (int i=0; i < s.length(); i++) {
        char c=s.charAt(i);
        if (c != '-' && c != '.' && (c < '0' || c > '9'))         throw new NumberFormatException();
      }
      d=Double.parseDouble(s);
      val=new Double(d);
    }
 catch (    NumberFormatException nfe) {
      val=new Double(Double.NaN);
    }
  }
 else   if (o instanceof Date) {
    val=new Double(DateUtils.daysSinceEpoch((Date)o));
  }
 else   if (o instanceof IExprDataType) {
    val=((IExprDataType)o).toNumeric();
  }
  if (val != null) {
    return val;
  }
 else {
    throw new XPathTypeMismatchException("String_Node_Str" + (o == null ? "String_Node_Str" : o.toString()) + "String_Node_Str");
  }
}
Program: 146890
Project: 146890
Buggy source:
public XPathNodeset eval(DataInstance m,EvaluationContext ec){
  TreeReference genericRef=getReference();
  TreeReference ref=genericRef.contextualize(ec.getContextRef());
  if (ref.getInstanceName() != null && ref.isAbsolute()) {
    DataInstance nonMain=ec.getInstance(ref.getInstanceName());
    if (nonMain != null) {
      m=nonMain;
    }
 else {
      throw new XPathTypeMismatchException("String_Node_Str" + ref.toString(true) + "String_Node_Str");
    }
  }
  if (ref.isAbsolute() && m.getTemplatePath(ref) == null) {
    throw new XPathTypeMismatchException("String_Node_Str" + genericRef.toString() + "String_Node_Str");
  }
  Vector<TreeReference> nodesetRefs=ec.expandReference(ref);
  for (int i=0; i < nodesetRefs.size(); i++) {
    if (!m.resolveReference((TreeReference)nodesetRefs.elementAt(i)).isRelevant()) {
      nodesetRefs.removeElementAt(i);
      i--;
    }
  }
  return new XPathNodeset(nodesetRefs,m,ec);
}

Fixed version (ground truth):
public XPathNodeset eval(DataInstance m,EvaluationContext ec){
  TreeReference genericRef=getReference();
  TreeReference ref=genericRef.contextualize(ec.getContextRef());
  if (ref.getInstanceName() != null && ref.isAbsolute()) {
    DataInstance nonMain=ec.getInstance(ref.getInstanceName());
    if (nonMain != null) {
      m=nonMain;
    }
 else {
      throw new XPathTypeMismatchException("String_Node_Str" + ref.toString(true) + "String_Node_Str");
    }
  }
 else {
    m=ec.getMainInstance();
  }
  if (ref.isAbsolute() && m.getTemplatePath(ref) == null) {
    throw new XPathTypeMismatchException("String_Node_Str" + genericRef.toString() + "String_Node_Str");
  }
  Vector<TreeReference> nodesetRefs=ec.expandReference(ref);
  for (int i=0; i < nodesetRefs.size(); i++) {
    if (!m.resolveReference((TreeReference)nodesetRefs.elementAt(i)).isRelevant()) {
      nodesetRefs.removeElementAt(i);
      i--;
    }
  }
  return new XPathNodeset(nodesetRefs,m,ec);
}
Program: 146892
Project: 146892
Buggy source:
public Object pivot(FormInstance model,EvaluationContext evalContext,Vector<Object> pivots,Object sentinal) throws UnpivotableExpressionException {
  Object aval=a.pivot(model,evalContext,pivots,sentinal);
  Object bval=b.pivot(model,evalContext,pivots,sentinal);
  if (aval == sentinal || bval == sentinal) {
    throw new UnpivotableExpressionException();
  }
  if (aval == null || bval == null) {
    return null;
  }
  return this.eval(model,evalContext);
}

Fixed version (ground truth):
public Object pivot(DataInstance model,EvaluationContext evalContext,Vector<Object> pivots,Object sentinal) throws UnpivotableExpressionException {
  Object aval=a.pivot(model,evalContext,pivots,sentinal);
  Object bval=b.pivot(model,evalContext,pivots,sentinal);
  if (aval == sentinal || bval == sentinal) {
    throw new UnpivotableExpressionException();
  }
  if (aval == null || bval == null) {
    return null;
  }
  return this.eval(model,evalContext);
}
Program: 146893
Project: 146893
Buggy source:
public Object pivot(FormInstance model,EvaluationContext evalContext,Vector<Object> pivots,Object sentinal) throws UnpivotableExpressionException {
  Object aval=a.pivot(model,evalContext,pivots,sentinal);
  Object bval=b.pivot(model,evalContext,pivots,sentinal);
  if (handled(aval,bval,sentinal,pivots) || handled(bval,aval,sentinal,pivots)) {
    return null;
  }
  return this.eval(model,evalContext);
}

Fixed version (ground truth):
public Object pivot(DataInstance model,EvaluationContext evalContext,Vector<Object> pivots,Object sentinal) throws UnpivotableExpressionException {
  Object aval=a.pivot(model,evalContext,pivots,sentinal);
  Object bval=b.pivot(model,evalContext,pivots,sentinal);
  if (handled(aval,bval,sentinal,pivots) || handled(bval,aval,sentinal,pivots)) {
    return null;
  }
  return this.eval(model,evalContext);
}
Program: 146894
Project: 146894
Buggy source:
public Object pivot(FormInstance model,EvaluationContext evalContext,Vector<Object> pivots,Object sentinal) throws UnpivotableExpressionException {
  throw new UnpivotableExpressionException();
}

Fixed version (ground truth):
public Object pivot(DataInstance model,EvaluationContext evalContext,Vector<Object> pivots,Object sentinal) throws UnpivotableExpressionException {
  throw new UnpivotableExpressionException();
}
Program: 146895
Project: 146895
Buggy source:
/** 
 */
public Object pivot(FormInstance model,EvaluationContext evalContext,Vector<Object> pivots,Object sentinal) throws UnpivotableExpressionException {
  String name=id.toString();
  Object[] argVals=new Object[args.length];
  String[] identities=new String[]{"String_Node_Str"};
  boolean id=false;
  for (  String identity : identities) {
    if (identity.equals(name)) {
      id=true;
    }
  }
  for (int i=0; i < args.length; i++) {
    argVals[i]=args[i].pivot(model,evalContext,pivots,sentinal);
  }
  boolean pivoted=false;
  for (int i=0; i < argVals.length; ++i) {
    if (argVals[i] == null) {
      pivoted=true;
    }
 else     if (sentinal.equals(argVals[i])) {
      if (id) {
        return sentinal;
      }
 else {
        throw new UnpivotableExpressionException();
      }
    }
  }
  if (pivoted) {
    if (id) {
      return null;
    }
 else {
      throw new UnpivotableExpressionException();
    }
  }
  return eval(model,evalContext);
}

Fixed version (ground truth):
/** 
 */
public Object pivot(DataInstance model,EvaluationContext evalContext,Vector<Object> pivots,Object sentinal) throws UnpivotableExpressionException {
  String name=id.toString();
  Object[] argVals=new Object[args.length];
  String[] identities=new String[]{"String_Node_Str"};
  boolean id=false;
  for (  String identity : identities) {
    if (identity.equals(name)) {
      id=true;
    }
  }
  for (int i=0; i < args.length; i++) {
    argVals[i]=args[i].pivot(model,evalContext,pivots,sentinal);
  }
  boolean pivoted=false;
  for (int i=0; i < argVals.length; ++i) {
    if (argVals[i] == null) {
      pivoted=true;
    }
 else     if (sentinal.equals(argVals[i])) {
      if (id) {
        return sentinal;
      }
 else {
        throw new UnpivotableExpressionException();
      }
    }
  }
  if (pivoted) {
    if (id) {
      return null;
    }
 else {
      throw new UnpivotableExpressionException();
    }
  }
  return eval(model,evalContext);
}
Program: 146896
Project: 146896
Buggy source:
public Object pivot(FormInstance model,EvaluationContext evalContext,Vector<Object> pivots,Object sentinal) throws UnpivotableExpressionException {
  TreeReference ref=this.getReference();
  if (ref.equals(sentinal) || (ref.getRefLevel() == 0)) {
    return sentinal;
  }
 else {
    return this.eval(model,evalContext);
  }
}

Fixed version (ground truth):
public Object pivot(DataInstance model,EvaluationContext evalContext,Vector<Object> pivots,Object sentinal) throws UnpivotableExpressionException {
  TreeReference ref=this.getReference();
  if (ref.equals(sentinal) || (ref.getRefLevel() == 0)) {
    return sentinal;
  }
 else {
    return this.eval(model,evalContext);
  }
}
Program: 146897
Project: 146897
Buggy source:
public String[] getSortFields(){
  String[] names=getSortFieldNames();
  String[] ret=new String[names.length];
  int defaultSort=getSortFieldDefault();
  if (defaultSort != -1) {
    ret[0]=String.valueOf(defaultSort);
    ret[1]="String_Node_Str";
  }
 else {
    ret[0]="String_Node_Str";
  }
  for (int i=1; i < ret.length; ++i) {
    if (defaultSort != i) {
      ret[i]=String.valueOf(i);
    }
  }
  return ret;
}

Fixed version (ground truth):
public String[] getSortFields(){
  String[] names=getSortFieldNames();
  String[] ret=new String[names.length];
  int defaultSort=getSortFieldDefault();
  if (defaultSort != -1) {
    ret[0]=String.valueOf(defaultSort);
    ret[1]="String_Node_Str";
  }
 else {
    ret[0]="String_Node_Str";
  }
  int position=defaultSort == -1 ? 1 : 2;
  for (int i=1; i < ret.length; ++i) {
    if (defaultSort != i) {
      ret[position]=String.valueOf(i);
      position++;
    }
  }
  return ret;
}
Program: 146898
Project: 146898
Buggy source:
public String[] getSortFieldNames(){
  Vector<String> fields=new Vector<String>();
  fields.addElement(Localization.get("String_Node_Str"));
  for (  String s : getHeaders(false)) {
    if (s == null || "String_Node_Str".equals(s)) {
      continue;
    }
    fields.addElement(s);
  }
  String[] ret=new String[fields.size()];
  for (int i=0; i < ret.length; ++i) {
    ret[i]=fields.elementAt(i);
  }
  return ret;
}

Fixed version (ground truth):
public String[] getSortFieldNames(){
  Vector<String> fields=new Vector<String>();
  int sortField=this.getSortFieldDefault() - 1;
  String[] headers=getHeaders(false);
  if (sortField == -1) {
    fields.addElement(Localization.get("String_Node_Str"));
  }
 else {
    fields.addElement(headers[sortField]);
    fields.addElement(Localization.get("String_Node_Str"));
  }
  for (int i=0; i < headers.length; ++i) {
    if (i == sortField) {
      continue;
    }
    String s=headers[i];
    if (s == null || "String_Node_Str".equals(s)) {
      continue;
    }
    fields.addElement(s);
  }
  String[] ret=new String[fields.size()];
  for (int i=0; i < ret.length; ++i) {
    ret[i]=fields.elementAt(i);
  }
  return ret;
}
Program: 146899
Project: 146899
Buggy source:
private int getSortFieldDefault(){
  int topIndex=shortDetail.getDefaultSort();
  if (topIndex == -1) {
    return -1;
  }
  int index=-1;
  Vector<String> fields=new Vector<String>();
  fields.addElement(Localization.get("String_Node_Str"));
  String[] headers=getHeaders(false);
  for (int i=0; i < headers.length; ++i) {
    if (i == topIndex) {
      return fields.size();
    }
  }
  return -1;
}

Fixed version (ground truth):
private int getSortFieldDefault(){
  int topIndex=shortDetail.getDefaultSort();
  if (topIndex == -1) {
    return -1;
  }
  int index=-1;
  Vector<String> fields=new Vector<String>();
  fields.addElement(Localization.get("String_Node_Str"));
  String[] headers=getHeaders(false);
  for (int i=0; i < headers.length; ++i) {
    fields.addElement(headers[i]);
    if (i == topIndex) {
      return fields.size() - 1;
    }
  }
  return -1;
}
Program: 146901
Project: 146901
Buggy source:
public Object getValue(){
  return new Integer(n);
}

Fixed version (ground truth):
public Object getValue(){
  return DataUtil.integer(n);
}
Program: 146902
Project: 146902
Buggy source:
public UncastData uncast(){
  return new UncastData(new Integer(n).toString());
}

Fixed version (ground truth):
public UncastData uncast(){
  return new UncastData(DataUtil.integer(n).toString());
}
Program: 146903
Project: 146903
Buggy source:
public Vector<XPathExpression> getPredicate(int key){
  return predicates.get(new Integer(key));
}

Fixed version (ground truth):
public Vector<XPathExpression> getPredicate(int key){
  return predicates.get(DataUtil.integer(key));
}
Program: 146904
Project: 146904
Buggy source:
public int hashCode(){
  int hash=(new Integer(refLevel)).hashCode();
  for (int i=0; i < size(); i++) {
    Integer mult=new Integer(getMultiplicity(i));
    if (i == 0 && mult.intValue() == INDEX_UNBOUND)     mult=new Integer(0);
    hash^=getName(i).hashCode();
    hash^=mult.hashCode();
  }
  return hash;
}

Fixed version (ground truth):
public int hashCode(){
  int hash=(new Integer(refLevel)).hashCode();
  for (int i=0; i < size(); i++) {
    Integer mult=DataUtil.integer(getMultiplicity(i));
    if (i == 0 && mult.intValue() == INDEX_UNBOUND)     mult=DataUtil.integer(0);
    hash^=getName(i).hashCode();
    hash^=mult.hashCode();
  }
  return hash;
}
Program: 146905
Project: 146905
Buggy source:
public void add(String name,int index){
  names.addElement(name);
  multiplicity.addElement(new Integer(index));
}

Fixed version (ground truth):
public void add(String name,int index){
  names.addElement(name);
  multiplicity.addElement(DataUtil.integer(index));
}
Program: 146906
Project: 146906
Buggy source:
public TreeReference(){
  names=new Vector(0);
  multiplicity=new Vector(0);
  predicates=new Hashtable<Integer,Vector<XPathExpression>>();
  instanceName=null;
}

Fixed version (ground truth):
public TreeReference(){
  names=new Vector(0);
  multiplicity=new Vector(0);
  predicates=new Hashtable<Integer,Vector<XPathExpression>>(0);
  instanceName=null;
}
Program: 146907
Project: 146907
Buggy source:
public void setMultiplicity(int i,int mult){
  multiplicity.setElementAt(new Integer(mult),i);
}

Fixed version (ground truth):
public void setMultiplicity(int i,int mult){
  multiplicity.setElementAt(DataUtil.integer(mult),i);
}
Program: 146908
Project: 146908
Buggy source:
public void addPredicate(int key,Vector<XPathExpression> xpe){
  predicates.put(new Integer(key),xpe);
}

Fixed version (ground truth):
public void addPredicate(int key,Vector<XPathExpression> xpe){
  predicates.put(DataUtil.integer(key),xpe);
}
Program: 146910
Project: 146910
Buggy source:
private static void loadInstanceData(Element node,TreeElement cur,FormDef f){
  int numChildren=node.getChildCount();
  boolean hasElements=false;
  for (int i=0; i < numChildren; i++) {
    if (node.getType(i) == Node.ELEMENT) {
      hasElements=true;
      break;
    }
  }
  if (hasElements) {
    Hashtable<String,Integer> multiplicities=new Hashtable<String,Integer>();
    for (int i=0; i < numChildren; i++) {
      if (node.getType(i) == Node.ELEMENT) {
        Element child=node.getElement(i);
        String name=child.getName();
        int index;
        boolean isTemplate=(child.getAttributeValue(NAMESPACE_JAVAROSA,"String_Node_Str") != null);
        if (isTemplate) {
          index=TreeReference.INDEX_TEMPLATE;
        }
 else {
          Integer mult=multiplicities.get(name);
          index=(mult == null ? 0 : mult.intValue() + 1);
          multiplicities.put(name,new Integer(index));
        }
        loadInstanceData(child,cur.getChild(name,index),f);
      }
    }
  }
 else {
    String text=getXMLText(node,false);
    if (text != null && text.trim().length() > 0) {
      cur.setValue(XFormAnswerDataParser.getAnswerData(text,cur.getDataType(),ghettoGetQuestionDef(cur.getDataType(),f,cur.getRef())));
    }
  }
}

Fixed version (ground truth):
private static void loadInstanceData(Element node,TreeElement cur,FormDef f){
  int numChildren=node.getChildCount();
  boolean hasElements=false;
  for (int i=0; i < numChildren; i++) {
    if (node.getType(i) == Node.ELEMENT) {
      hasElements=true;
      break;
    }
  }
  if (hasElements) {
    Hashtable<String,Integer> multiplicities=new Hashtable<String,Integer>();
    for (int i=0; i < numChildren; i++) {
      if (node.getType(i) == Node.ELEMENT) {
        Element child=node.getElement(i);
        String name=child.getName();
        int index;
        boolean isTemplate=(child.getAttributeValue(NAMESPACE_JAVAROSA,"String_Node_Str") != null);
        if (isTemplate) {
          index=TreeReference.INDEX_TEMPLATE;
        }
 else {
          Integer mult=multiplicities.get(name);
          index=(mult == null ? 0 : mult.intValue() + 1);
          multiplicities.put(name,DataUtil.integer(index));
        }
        loadInstanceData(child,cur.getChild(name,index),f);
      }
    }
  }
 else {
    String text=getXMLText(node,false);
    if (text != null && text.trim().length() > 0) {
      cur.setValue(XFormAnswerDataParser.getAnswerData(text,cur.getDataType(),ghettoGetQuestionDef(cur.getDataType(),f,cur.getRef())));
    }
  }
}
Program: 146911
Project: 146911
Buggy source:
public static void addDataType(String type,int dataType){
  typeMappings.put(type,new Integer(dataType));
}

Fixed version (ground truth):
public static void addDataType(String type,int dataType){
  typeMappings.put(type,DataUtil.integer(dataType));
}
Program: 146912
Project: 146912
Buggy source:
public RMSStorageIterator(RMSStorageUtility store,Hashtable index){
  SortedIntSet IDs=new SortedIntSet();
  for (Enumeration e=index.keys(); e.hasMoreElements(); ) {
    IDs.add(((Integer)e.nextElement()).intValue());
  }
  this.index=index;
  this.store=store;
  this.IDs=IDs.getVector();
  pos=0;
  valid=true;
}

Fixed version (ground truth):
public RMSStorageIterator(RMSStorageUtility store,IdIndex index){
  SortedIntSet IDs=new SortedIntSet();
  for (Enumeration e=index.getIndexTable().keys(); e.hasMoreElements(); ) {
    IDs.add(((Integer)e.nextElement()).intValue());
  }
  this.index=index;
  this.store=store;
  this.IDs=IDs.getVector();
  pos=0;
  valid=true;
}
Program: 146913
Project: 146913
Buggy source:
/** 
 * Add a Condition to the form's Collection.
 * @param condition the condition to be set
 */
public Triggerable addTriggerable(Triggerable t){
  int existingIx=triggerables.indexOf(t);
  if (existingIx >= 0) {
    return (Triggerable)triggerables.elementAt(existingIx);
  }
 else {
    triggerables.addElement(t);
    triggerablesInOrder=false;
    Vector triggers=t.getTriggers();
    for (int i=0; i < triggers.size(); i++) {
      TreeReference trigger=(TreeReference)triggers.elementAt(i);
      if (!triggerIndex.containsKey(trigger)) {
        triggerIndex.put(trigger,new Vector());
      }
      Vector triggered=(Vector)triggerIndex.get(trigger);
      if (!triggered.contains(t)) {
        triggered.addElement(t);
      }
    }
    return t;
  }
}

Fixed version (ground truth):
/** 
 * Add a Condition to the form's Collection.
 * @param condition the condition to be set
 */
public Triggerable addTriggerable(Triggerable t){
  int existingIx=triggerables.indexOf(t);
  if (existingIx >= 0) {
    Triggerable existingTriggerable=(Triggerable)triggerables.elementAt(existingIx);
    existingTriggerable.contextRef=existingTriggerable.contextRef.intersect(t.contextRef);
    return existingTriggerable;
  }
 else {
    triggerables.addElement(t);
    triggerablesInOrder=false;
    Vector triggers=t.getTriggers();
    for (int i=0; i < triggers.size(); i++) {
      TreeReference trigger=(TreeReference)triggers.elementAt(i);
      if (!triggerIndex.containsKey(trigger)) {
        triggerIndex.put(trigger,new Vector());
      }
      Vector triggered=(Vector)triggerIndex.get(trigger);
      if (!triggered.contains(t)) {
        triggered.addElement(t);
      }
    }
    return t;
  }
}