nus-yam/ex-repair huggingface dataset:
Program: 76441
Project: 76441
Buggy source:
/** 
 * Return a new array that is a copy of the argument except that the elements are limited to lie within the specified range. If any value is infinite or NaN (not a number), then it is replaced by either the top or the bottom, depending on its sign.  To leave either the bottom or the top unconstrained, specify Double.MIN_VALUE or Double.MAX_VALUE. If the size of the array is 0, return a new array of size 0.
 * @param array An array of doubles.
 * @param bottom The bottom limit.
 * @param top The top limit.
 * @return A new array with values in the range [bottom, top].
 */
public final static double[] limit(double[] array,double bottom,double top){
  double[] result=new double[array.length];
  for (int i=0; i < array.length; i++) {
    if (array[i] > top || array[i] == Double.NaN || array[i] == Double.POSITIVE_INFINITY) {
      result[i]=top;
    }
 else     if (array[i] < bottom || array[i] == -Double.NaN || array[i] == Double.NEGATIVE_INFINITY) {
      result[i]=bottom;
    }
 else {
      result[i]=array[i];
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Return a new array that is a copy of the argument except that the elements are limited to lie within the specified range. If any value is infinite or NaN (not a number), then it is replaced by either the top or the bottom, depending on its sign.  To leave either the bottom or the top unconstrained, specify Double.NEGATIVE_INFINITY or Double.POSITIVE_INFINITY. If the size of the array is 0, return a new array of size 0.
 * @param array An array of doubles.
 * @param bottom The bottom limit.
 * @param top The top limit.
 * @return A new array with values in the range [bottom, top].
 */
public final static double[] limit(double[] array,double bottom,double top){
  double[] result=new double[array.length];
  for (int i=0; i < array.length; i++) {
    if ((array[i] > top) || (array[i] == Double.NaN) || (array[i] == Double.POSITIVE_INFINITY)) {
      result[i]=top;
    }
 else     if ((array[i] < bottom) || (array[i] == -Double.NaN) || (array[i] == Double.NEGATIVE_INFINITY)) {
      result[i]=bottom;
    }
 else {
      result[i]=array[i];
    }
  }
  return result;
}
Program: 76442
Project: 76442
Buggy source:
/** 
 * Return the next power of two larger than the argument.
 * @param x A positive real number.
 * @exception IllegalArgumentException If the argument is less thanor equal to zero. This is a runtime exception, so it need not be declared by the caller.
 */
public static int powerOfTwo(double x){
  if (x <= 0.0) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str" + x);
  }
  double m=Math.log(x) * _LOG2SCALE;
  int exp=(int)Math.ceil(m);
  return 1 << exp;
}

Fixed version (ground truth):
/** 
 * Return the next power of two larger than the argument.
 * @param x A positive real number.
 * @exception IllegalArgumentException If the argument is less thanor equal to zero.      
 */
public static int powerOfTwo(double x){
  if (x <= 0.0) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str" + x);
  }
  double m=Math.log(x) * _LOG2SCALE;
  int exp=(int)Math.ceil(m);
  return 1 << exp;
}
Program: 76443
Project: 76443
Buggy source:
private static double[] _DCT(double[] x,int size,int order){
  double[] retval;
  if (size == 2) {
    retval=new double[2];
    retval[0]=x[0] + x[1];
    retval[1]=_ONEOVERROOT2 * (x[0] - x[1]);
    return retval;
  }
  int halfN=size >> 1;
  double[] x4=new double[size];
  for (int n=0; n < halfN; n++) {
    int twoN=n << 1;
    x4[n]=x[twoN];
    x4[size - n - 1]=x[twoN + 1];
  }
  double[] cosDFTarray=_cosDFT(x4,size,order);
  double[] sinDFTarray=_sinDFT(x4,size,order);
  double[] p1tab=_P1Table[order];
  double[] p2tab=_P2Table[order];
  double[] ctab=_CTable[order];
  retval=new double[size];
  retval[0]=cosDFTarray[0];
  for (int k=1; k < halfN; k++) {
    double m1=(cosDFTarray[k] + sinDFTarray[k]) * ctab[k];
    double m2=sinDFTarray[k] * p1tab[k];
    double m3=cosDFTarray[k] * p2tab[k];
    retval[k]=m1 - m2;
    retval[size - k]=m1 + m3;
  }
  retval[halfN]=_ONEOVERROOT2 * cosDFTarray[halfN];
  return retval;
}

Fixed version (ground truth):
private static double[] _DCT(double[] x,int size,int order){
  double[] retval;
  if (size == 1) {
    retval=new double[1];
    retval[0]=x[0];
    return retval;
  }
  if (size == 2) {
    retval=new double[2];
    retval[0]=x[0] + x[1];
    retval[1]=_ONEOVERROOT2 * (x[0] - x[1]);
    return retval;
  }
  int halfN=size >> 1;
  double[] x4=new double[size];
  for (int n=0; n < halfN; n++) {
    int twoN=n << 1;
    x4[n]=x[twoN];
    x4[size - n - 1]=x[twoN + 1];
  }
  double[] cosDFTarray=_cosDFT(x4,size,order);
  double[] sinDFTarray=_sinDFT(x4,size,order);
  double[] p1tab=_P1Table[order];
  double[] p2tab=_P2Table[order];
  double[] ctab=_CTable[order];
  retval=new double[size];
  retval[0]=cosDFTarray[0];
  for (int k=1; k < halfN; k++) {
    double m1=(cosDFTarray[k] + sinDFTarray[k]) * ctab[k];
    double m2=sinDFTarray[k] * p1tab[k];
    double m3=cosDFTarray[k] * p2tab[k];
    retval[k]=m1 - m2;
    retval[size - k]=m1 + m3;
  }
  retval[halfN]=_ONEOVERROOT2 * cosDFTarray[halfN];
  return retval;
}
Program: 76444
Project: 76444
Buggy source:
/** 
 * Return the "order" of a transform size, i.e. the base-2 logarithm of the size. The order will be rounded up to the nearest integer.
 * @param size The size of the transform.
 * @retval The order of the transform.
 */
public static int order(int size){
  double m=Math.log(size) * _LOG2SCALE;
  double exp=Math.ceil(m);
  return (int)exp;
}

Fixed version (ground truth):
/** 
 * Return the "order" of a transform size, i.e. the base-2 logarithm of the size. The order will be rounded up to the nearest integer. If the size is zero or negative, throw an IllegalArgumentException.
 * @param size The size of the transform.
 * @retval The order of the transform.
 */
public static int order(int size){
  if (size <= 0) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  }
  double m=Math.log(size) * _LOG2SCALE;
  double exp=Math.ceil(m);
  return (int)exp;
}
Program: 76445
Project: 76445
Buggy source:
private static Complex[] _checkTransformArgs(Complex[] x,int order){
  _checkTransformInput(x);
  _checkTransformOrder(order);
  int size=1 << order;
  if (x.length < size) {
    x=ComplexArrayMath.resize(x,size);
  }
  return x;
}

Fixed version (ground truth):
private static Complex[] _checkTransformArgs(Complex[] x,int order){
  _checkTransformOrder(order);
  int size=1 << order;
  if (x.length < size) {
    x=ComplexArrayMath.resize(x,size);
  }
  return x;
}
Program: 76446
Project: 76446
Buggy source:
private static void _checkTransformOrder(int order){
  if (order < 1) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  }
 else   if (order > 31) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  }
}

Fixed version (ground truth):
private static void _checkTransformOrder(int order){
  if (order < 0) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  }
 else   if (order > 31) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  }
}
Program: 76447
Project: 76447
Buggy source:
/** 
 * Return a new array of doubles that is the forward DCT of the  input array of doubles. See the DCT_TYPE_XXX constants for documentation of the exact formula, which depends on the type.
 * @param x An array of doubles.
 * @param order The base-2 logarithm of the size of the transform.
 * @param type An integer specifying which type of DCT.
 * @retval A new array of doubles.
 */
public static double[] DCT(double[] x,int order,int type){
  if (type >= DCT_TYPES) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  }
  int size=1 << order;
  if (order > _FFCTGenLimit)   _FFCTTableGen(order);
  double[] retval=_DCT(x,size,order);
switch (type) {
case DCT_TYPE_ORTHONORMAL:
    double factor=Math.sqrt(2.0 / size);
  retval=DoubleArrayMath.scale(retval,factor);
case DCT_TYPE_NORMALIZED:
retval[0]*=_ONEOVERROOT2;
break;
}
return retval;
}

Fixed version (ground truth):
/** 
 * Return a new array of doubles that is the forward DCT of the  input array of doubles. See the DCT_TYPE_XXX constants for documentation of the exact formula, which depends on the type.
 * @param x An array of doubles.
 * @param order The base-2 logarithm of the size of the transform.
 * @param type An integer specifying which type of DCT.
 * @retval A new array of doubles.
 */
public static double[] DCT(double[] x,int order,int type){
  _checkTransformArgs(x,order);
  if (type >= DCT_TYPES) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  }
  int size=1 << order;
  if (order > _FFCTGenLimit)   _FFCTTableGen(order);
  double[] retval=_DCT(x,size,order);
switch (type) {
case DCT_TYPE_ORTHONORMAL:
    double factor=Math.sqrt(2.0 / size);
  retval=DoubleArrayMath.scale(retval,factor);
case DCT_TYPE_NORMALIZED:
retval[0]*=_ONEOVERROOT2;
break;
}
return retval;
}
Program: 76448
Project: 76448
Buggy source:
private Object _leastElementNodeId(int[] ids){
  LinkedList incompList=new LinkedList();
  int candidate=-1;
  for (int i=0; i < ids.length; i++) {
    boolean listEmpty=incompList.size() == 0;
    if (candidate == -1 && listEmpty) {
      candidate=ids[i];
    }
 else     if (candidate != -1 && listEmpty) {
      int result=_compareNodeId(ids[i],candidate);
      if (result == LOWER) {
        candidate=ids[i];
      }
 else       if (result == INCOMPARABLE) {
        incompList.insertLast(new Integer(candidate));
        incompList.insertLast(new Integer(ids[i]));
        candidate=-1;
      }
    }
 else     if (candidate == -1 && !listEmpty) {
      boolean discard=false;
      LinkedList newList=new LinkedList();
      for (Enumeration e=incompList.elements(); e.hasMoreElements(); ) {
        Integer node=(Integer)e.nextElement();
        int listValue=node.intValue();
        int result=_compareNodeId(ids[i],listValue);
        if (result == LOWER) {
        }
 else         if (result == HIGHER) {
          discard=true;
          newList.insertLast(node);
          break;
        }
 else {
          newList.insertLast(node);
        }
      }
      incompList=newList;
      if (incompList.size() == 0) {
        candidate=ids[i];
      }
 else       if (!discard) {
        incompList.insertLast(_getNodeObject(ids[i]));
      }
    }
 else {
      throw new InvalidStateException("String_Node_Str" + "String_Node_Str");
    }
  }
  if (candidate == -1) {
    return null;
  }
 else {
    return _getNodeObject(candidate);
  }
}

Fixed version (ground truth):
private Object _leastElementNodeId(int[] ids){
  LinkedList incompList=new LinkedList();
  int candidate=-1;
  for (int i=0; i < ids.length; i++) {
    boolean listEmpty=incompList.size() == 0;
    if (candidate == -1 && listEmpty) {
      candidate=ids[i];
    }
 else     if (candidate != -1 && listEmpty) {
      int result=_compareNodeId(ids[i],candidate);
      if (result == LOWER) {
        candidate=ids[i];
      }
 else       if (result == INCOMPARABLE) {
        incompList.insertLast(new Integer(candidate));
        incompList.insertLast(new Integer(ids[i]));
        candidate=-1;
      }
    }
 else     if (candidate == -1 && !listEmpty) {
      boolean discard=false;
      LinkedList newList=new LinkedList();
      for (Enumeration e=incompList.elements(); e.hasMoreElements(); ) {
        Integer node=(Integer)e.nextElement();
        int listValue=node.intValue();
        int result=_compareNodeId(ids[i],listValue);
        if (result == LOWER) {
        }
 else         if (result == HIGHER) {
          discard=true;
          newList.insertLast(node);
          break;
        }
 else {
          newList.insertLast(node);
        }
      }
      incompList=newList;
      if (incompList.size() == 0) {
        candidate=ids[i];
      }
 else       if (!discard) {
        incompList.insertLast(new Integer(ids[i]));
      }
    }
 else {
      throw new InvalidStateException("String_Node_Str" + "String_Node_Str");
    }
  }
  if (candidate == -1) {
    return null;
  }
 else {
    return _getNodeObject(candidate);
  }
}
Program: 76449
Project: 76449
Buggy source:
private Object _leastElementNodeId(int[] ids){
  LinkedList incompList=new LinkedList();
  int candidate=-1;
  for (int i=0; i < ids.length; i++) {
    boolean listEmpty=incompList.size() == 0;
    if (candidate == -1 && listEmpty) {
      candidate=ids[i];
    }
 else     if (candidate != -1 && listEmpty) {
      int result=_compareNodeId(ids[i],candidate);
      if (result == LOWER) {
        candidate=ids[i];
      }
 else       if (result == INCOMPARABLE) {
        incompList.insertLast(new Integer(candidate));
        incompList.insertLast(new Integer(ids[i]));
        candidate=-1;
      }
    }
 else     if (candidate == -1 && !listEmpty) {
      boolean discard=false;
      LinkedList newList=new LinkedList();
      for (Enumeration e=incompList.elements(); e.hasMoreElements(); ) {
        Integer node=(Integer)e.nextElement();
        int listValue=node.intValue();
        int result=_compareNodeId(ids[i],listValue);
        if (result == LOWER) {
        }
 else         if (result == HIGHER) {
          discard=true;
          newList.insertLast(node);
          break;
        }
 else {
          newList.insertLast(node);
        }
      }
      incompList=newList;
      if (incompList.size() == 0) {
        candidate=ids[i];
      }
 else       if (!discard) {
        incompList.insertLast(new Integer(ids[i]));
      }
    }
 else {
      throw new InvalidStateException("String_Node_Str" + "String_Node_Str");
    }
  }
  if (candidate == -1) {
    return null;
  }
 else {
    return _getNodeObject(candidate);
  }
}

Fixed version (ground truth):
private Object _leastElementNodeId(int[] ids){
  LinkedList incompList=new LinkedList();
  int candidate=-1;
  for (int i=0; i < ids.length; i++) {
    boolean listEmpty=incompList.size() == 0;
    if (candidate == -1 && listEmpty) {
      candidate=ids[i];
    }
 else     if (candidate != -1 && listEmpty) {
      int result=_compareNodeId(ids[i],candidate);
      if (result == LOWER) {
        candidate=ids[i];
      }
 else       if (result == INCOMPARABLE) {
        incompList.insertLast(new Integer(candidate));
        incompList.insertLast(new Integer(ids[i]));
        candidate=-1;
      }
    }
 else     if (candidate == -1 && !listEmpty) {
      boolean discard=false;
      LinkedList newList=new LinkedList();
      for (Enumeration e=incompList.elements(); e.hasMoreElements(); ) {
        Integer node=(Integer)e.nextElement();
        int listValue=node.intValue();
        int result=_compareNodeId(ids[i],listValue);
        if (result == LOWER) {
        }
 else         if (result == HIGHER || result == SAME) {
          discard=true;
          newList=incompList;
          break;
        }
 else {
          newList.insertLast(node);
        }
      }
      incompList=newList;
      if (incompList.size() == 0) {
        candidate=ids[i];
      }
 else       if (!discard) {
        incompList.insertLast(new Integer(ids[i]));
      }
    }
 else {
      throw new InvalidStateException("String_Node_Str" + "String_Node_Str");
    }
  }
  if (candidate == -1) {
    return null;
  }
 else {
    return _getNodeObject(candidate);
  }
}
Program: 76450
Project: 76450
Buggy source:
private static double[] _cosDFT(double[] x,int size,int order){
  if (size == 4) {
    double[] retval=new double[3];
    retval[0]=x[0] + x[1] + x[2]+ x[3];
    retval[1]=x[0] - x[2];
    retval[2]=x[0] - x[1] + x[2] - x[3];
    return retval;
  }
  int halfN=size >> 1;
  int quarterN=size >> 2;
  double[] x1=new double[halfN];
  for (int k=0; k < halfN; k++) {
    x1[k]=x[k << 1];
  }
  double[] x2=new double[quarterN];
  for (int k=0; k < quarterN; k++) {
    int twoIp=(k << 1) + 1;
    x2[k]=x[twoIp] + x[size - twoIp];
  }
  double[] halfCosDFT=_cosDFT(x1,halfN,order - 1);
  double[] quarterDCT=_DCT(x2,quarterN,order - 2);
  double[] retval=new double[halfN + 1];
  for (int k=0; k < quarterN; k++) {
    retval[k]=halfCosDFT[k] + quarterDCT[k];
  }
  retval[quarterN]=halfCosDFT[quarterN];
  for (int k=quarterN + 1; k <= halfN; k++) {
    int idx=halfN - k;
    retval[k]=halfCosDFT[idx] - quarterDCT[idx];
  }
  return retval;
}

Fixed version (ground truth):
private static double[] _cosDFT(double[] x,int size,int order){
switch (size) {
case 0:
    return new double[0];
case 1:
{
    double[] retval=new double[1];
    retval[0]=x[0];
    return retval;
  }
case 2:
{
  double[] retval=new double[2];
  retval[0]=x[0] + x[1];
  retval[1]=x[0] - x[1];
  return retval;
}
case 4:
{
double[] retval=new double[3];
retval[0]=x[0] + x[1] + x[2]+ x[3];
retval[1]=x[0] - x[2];
retval[2]=x[0] - x[1] + x[2] - x[3];
return retval;
}
}
int halfN=size >> 1;
int quarterN=size >> 2;
double[] x1=new double[halfN];
for (int k=0; k < halfN; k++) {
x1[k]=x[k << 1];
}
double[] x2=new double[quarterN];
for (int k=0; k < quarterN; k++) {
int twoIp=(k << 1) + 1;
x2[k]=x[twoIp] + x[size - twoIp];
}
double[] halfCosDFT=_cosDFT(x1,halfN,order - 1);
double[] quarterDCT=_DCT(x2,quarterN,order - 2);
double[] retval=new double[halfN + 1];
for (int k=0; k < quarterN; k++) {
retval[k]=halfCosDFT[k] + quarterDCT[k];
}
retval[quarterN]=halfCosDFT[quarterN];
for (int k=quarterN + 1; k <= halfN; k++) {
int idx=halfN - k;
retval[k]=halfCosDFT[idx] - quarterDCT[idx];
}
return retval;
}
Program: 76451
Project: 76451
Buggy source:
private static double[] _sinDFT(double[] x,int size,int order){
  if (size == 4) {
    double[] retval=new double[2];
    retval[1]=x[1] - x[3];
    return retval;
  }
  int halfN=size >> 1;
  int quarterN=size >> 2;
  double[] x1=new double[halfN];
  for (int k=0; k < halfN; k++) {
    x1[k]=x[k << 1];
  }
  double[] x3=new double[quarterN];
  for (int k=0; k < quarterN; k++) {
    int twoIp=(k << 1) + 1;
    x3[k]=((k & 1) == 1) ? (x[size - twoIp] - x[twoIp]) : (x[twoIp] - x[size - twoIp]);
  }
  double[] halfSinDFT=_sinDFT(x1,halfN,order - 1);
  double[] quarterDCT=_DCT(x3,quarterN,order - 2);
  double[] retval=new double[halfN];
  for (int k=1; k < quarterN; k++) {
    retval[k]=halfSinDFT[k] + quarterDCT[quarterN - k];
  }
  retval[quarterN]=quarterDCT[0];
  for (int k=quarterN + 1; k < halfN; k++) {
    retval[k]=quarterDCT[k - quarterN] - halfSinDFT[halfN - k];
  }
  return retval;
}

Fixed version (ground truth):
private static double[] _sinDFT(double[] x,int size,int order){
switch (size) {
case 0:
case 1:
case 2:
    return null;
case 4:
{
    double[] retval=new double[2];
    retval[1]=x[1] - x[3];
  }
}
int halfN=size >> 1;
int quarterN=size >> 2;
double[] x1=new double[halfN];
for (int k=0; k < halfN; k++) {
x1[k]=x[k << 1];
}
double[] x3=new double[quarterN];
for (int k=0; k < quarterN; k++) {
int twoIp=(k << 1) + 1;
x3[k]=((k & 1) == 1) ? (x[size - twoIp] - x[twoIp]) : (x[twoIp] - x[size - twoIp]);
}
double[] halfSinDFT=_sinDFT(x1,halfN,order - 1);
double[] quarterDCT=_DCT(x3,quarterN,order - 2);
double[] retval=new double[halfN];
for (int k=1; k < quarterN; k++) {
retval[k]=halfSinDFT[k] + quarterDCT[quarterN - k];
}
retval[quarterN]=quarterDCT[0];
for (int k=quarterN + 1; k < halfN; k++) {
retval[k]=quarterDCT[k - quarterN] - halfSinDFT[halfN - k];
}
return retval;
}
Program: 76452
Project: 76452
Buggy source:
/** 
 * Set the Manager for execution of this CompositeActor. This can only be done for a composite actor that has no container. For others, the Manager is inherited from the container. This method is write-synchronized on the workspace.
 * @param manager The Manager
 * @exception IllegalActionException If this actor has a container.
 * @see getManager
 */
public void setManager(Manager manager) throws IllegalActionException {
  try {
    workspace().getWriteAccess();
    if (getContainer() != null && manager != null) {
      throw new IllegalActionException(this,manager,"String_Node_Str" + "String_Node_Str");
    }
    if (_manager != null)     _manager._makeManagerOf(null);
    if (manager != null) {
      manager._makeManagerOf(this);
    }
    _manager=manager;
    return;
  }
  finally {
    workspace().doneWriting();
  }
}

Fixed version (ground truth):
/** 
 * Set the Manager for execution of this CompositeActor. This can only be done for a composite actor that has no container. For others, the Manager is inherited from the container. This method is write-synchronized on the workspace.
 * @param manager The Manager
 * @exception IllegalActionException If this actor already has a container, or the manager is not in the same workspace as this  actor.
 * @see getManager
 */
public void setManager(Manager manager) throws IllegalActionException {
  if (manager != null && workspace() != manager.workspace()) {
    throw new IllegalActionException(this,manager,"String_Node_Str");
  }
  try {
    workspace().getWriteAccess();
    if (getContainer() != null && manager != null) {
      throw new IllegalActionException(this,manager,"String_Node_Str" + "String_Node_Str");
    }
    if (_manager != null)     _manager._makeManagerOf(null);
    if (manager != null) {
      manager._makeManagerOf(this);
    }
    _manager=manager;
    return;
  }
  finally {
    workspace().doneWriting();
  }
}
Program: 76453
Project: 76453
Buggy source:
/** 
 * Set the local director for execution of this CompositeActor. Calling this method with a non-null argument makes this entity opaque. Calling it with a null argument makes it transparent. The container of the specified director is set to this composite actor, and if there was previously a local director, its container is set to null. This method is write-synchronized on the workspace.
 * @param director The Director responsible for execution.
 * @exception IllegalActionException Not thrown in this base class,but derived classes may throw it if the director is not compatible.
 */
public void setDirector(Director director) throws IllegalActionException {
  try {
    workspace().getWriteAccess();
    if (_director != null)     _director._makeDirectorOf(null);
    if (director != null) {
      director._makeDirectorOf(this);
    }
    _director=director;
  }
  finally {
    workspace().doneWriting();
  }
}

Fixed version (ground truth):
/** 
 * Set the local director for execution of this CompositeActor. Calling this method with a non-null argument makes this entity opaque. Calling it with a null argument makes it transparent. The container of the specified director is set to this composite actor, and if there was previously a local director, its container is set to null. This method is write-synchronized on the workspace.
 * @param director The Director responsible for execution.
 * @exception IllegalActionException If the director is not inthe same workspace as this actor.  It may also be throw in derived classed if the director is not compatible.
 */
public void setDirector(Director director) throws IllegalActionException {
  if (director != null && workspace() != director.workspace()) {
    throw new IllegalActionException(this,director,"String_Node_Str");
  }
  try {
    workspace().getWriteAccess();
    if (_director != null)     _director._makeDirectorOf(null);
    if (director != null) {
      director._makeDirectorOf(this);
    }
    _director=director;
  }
  finally {
    workspace().doneWriting();
  }
}
Program: 76454
Project: 76454
Buggy source:
/** 
 * Make this director the local director of the specified composite actor.  This method should not be called directly.  Instead, call setDirector of the CompositeActor class (or a derived class).
 */
protected void _makeDirectorOf(CompositeActor cast){
  _container=cast;
  if (cast != null) {
    workspace().remove(this);
  }
}

Fixed version (ground truth):
/** 
 * Make this director the local director of the specified composite actor.  If the CompositeActor is not null, then remove the Actor from the workspace directory. If the CompositeActor is null, then  the director is not added back into the directory of the Workspace,  which could result in it being garbage collected. This method should not be called directly.  Instead, call setDirector of the CompositeActor class (or a derived class).
 */
protected void _makeDirectorOf(CompositeActor cast){
  _container=cast;
  if (cast != null) {
    workspace().remove(this);
  }
}
Program: 76455
Project: 76455
Buggy source:
/** 
 * Make this Manager the Manager of the specified composite actor.  This method should not be called directly.  Instead, call setManager of the CompositeActor class (or a derived class). If the argument is not the toplevel CompositeActor, then we throw an InvalidStateException.
 */
protected void _makeManagerOf(CompositeActor ca){
  if (ca != null) {
    if (ca.getContainer() != null)     throw new InvalidStateException("String_Node_Str" + "String_Node_Str");
    workspace().remove(this);
  }
  _toplevel=ca;
}

Fixed version (ground truth):
/** 
 * Make this Manager the Manager of the specified composite actor. If the CompositeActor is not null, then the Manager is  removed from the directory of the workspace.  If the CompositeActor is null, then the MAnager is *not* returned to the directory of the workspace, which may result in it being garbage collected. This method should not be called directly.  Instead, call setManager of the CompositeActor class (or a derived class).
 */
protected void _makeManagerOf(CompositeActor ca){
  if (ca != null) {
    workspace().remove(this);
  }
  _toplevel=ca;
}
Program: 76456
Project: 76456
Buggy source:
/** 
 * Set the scheduler for this StaticSchedulingDirector. The container of the specified scheduler is set to this director. If there was a previous scheduler, the container of that scheduler is set to null. This method is write-synchronized on the workspace. If the scheduler is not compatible with the director, an IllegalActionException is thrown.
 * @param director The Director responsible for execution.
 * @exception IllegalActionException Not thrown in this base class,but derived classes may throw it if the scheduler is not compatible.
 */
public void setScheduler(Scheduler scheduler) throws IllegalActionException {
  try {
    workspace().getWriteAccess();
    if (_scheduler != null)     _scheduler._makeSchedulerOf(null);
    if (scheduler != null) {
      scheduler._makeSchedulerOf(this);
    }
    _scheduler=scheduler;
  }
  finally {
    workspace().doneWriting();
  }
}

Fixed version (ground truth):
/** 
 * Set the scheduler for this StaticSchedulingDirector. The container of the specified scheduler is set to this director. If there was a previous scheduler, the container of that scheduler is set to null. This method is write-synchronized on the workspace. If the scheduler is not compatible with the director, an IllegalActionException is thrown.
 * @param director The Director responsible for execution.
 * @exception IllegalActionException Not thrown in this base class,but derived classes may throw it if the scheduler is not compatible.
 */
public void setScheduler(Scheduler scheduler) throws IllegalActionException {
  if (scheduler != null && workspace() != scheduler.workspace()) {
    throw new IllegalActionException(this,scheduler,"String_Node_Str");
  }
  try {
    workspace().getWriteAccess();
    if (_scheduler != null)     _scheduler._makeSchedulerOf(null);
    if (scheduler != null) {
      scheduler._makeSchedulerOf(this);
    }
    _scheduler=scheduler;
  }
  finally {
    workspace().doneWriting();
  }
}
Program: 76458
Project: 76458
Buggy source:
/** 
 * Put an array of objects in the queue and return true if this will not cause the capacity to be exceeded. Otherwise, do not put any of the object in the queue and return false.
 * @param element An array of objects to be put in the queue.
 * @return A boolean indicating success.
 */
public boolean putArray(Object element[]){
  if (_queuearray.length - _queuesize >= element.length) {
    int i;
    if (element.length <= (_queuearray.length - _queuefront)) {
      System.arraycopy(element,0,_queuearray,_queuefront,element.length);
      _queuefront+=element.length;
      if (_queuefront >= _queuearray.length)       _queuefront=_queuefront % _queuearray.length;
      _queuesize+=element.length;
    }
 else {
      System.arraycopy(element,0,_queuearray,_queuefront,_queuearray.length - _queuefront);
      System.arraycopy(element,_queuearray.length - _queuefront,_queuearray,0,element.length - (_queuearray.length - _queuefront));
      _queuefront+=element.length;
      if (_queuefront >= _queuearray.length)       _queuefront=_queuefront % _queuearray.length;
      _queuesize+=element.length;
    }
    return true;
  }
 else {
    if (_queuemaxcapacity == INFINITE_CAPACITY) {
      try {
        _resizeArray(_queuearray.length * 2);
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
      return put(element);
    }
 else     return false;
  }
}

Fixed version (ground truth):
/** 
 * Put an array of objects in the queue and return true if this will not cause the capacity to be exceeded. Otherwise, do not put any of the object in the queue and return false.
 * @param element An array of objects to be put in the queue.
 * @return A boolean indicating success.
 */
public boolean putArray(Object element[]){
  if (_queuearray.length - _queuesize >= element.length) {
    int i;
    if (element.length <= (_queuearray.length - _queuefront)) {
      System.arraycopy(element,0,_queuearray,_queuefront,element.length);
      _queuefront+=element.length;
      if (_queuefront >= _queuearray.length)       _queuefront=_queuefront % _queuearray.length;
      _queuesize+=element.length;
    }
 else {
      System.arraycopy(element,0,_queuearray,_queuefront,_queuearray.length - _queuefront);
      System.arraycopy(element,_queuearray.length - _queuefront,_queuearray,0,element.length - (_queuearray.length - _queuefront));
      _queuefront+=element.length;
      if (_queuefront >= _queuearray.length)       _queuefront=_queuefront % _queuearray.length;
      _queuesize+=element.length;
    }
    return true;
  }
 else {
    if (_queuemaxcapacity == INFINITE_CAPACITY) {
      try {
        _resizeArray(_queuearray.length * 2);
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
      return putArray(element);
    }
 else     return false;
  }
}
Program: 76459
Project: 76459
Buggy source:
/** 
 * Return true always. Set this input to last input.
 */
public boolean postfire() throws IllegalActionException {
  super.postfire();
  _lastInput=_thisInput;
  return true;
}

Fixed version (ground truth):
/** 
 * Return true always. Set this input to last input.
 */
public boolean postfire() throws IllegalActionException {
  super.postfire();
  _lastInput=_thisInput;
  _first=false;
  return true;
}
Program: 76460
Project: 76460
Buggy source:
/** 
 * consume this input.
 */
public void fire() throws IllegalActionException {
  _thisInput=((DoubleToken)input.get(0)).doubleValue();
  _success=true;
}

Fixed version (ground truth):
/** 
 * consume this input.
 */
public void fire() throws IllegalActionException {
  System.out.println("String_Node_Str" + getFullName() + "String_Node_Str");
  _thisInput=((DoubleToken)input.get(0)).doubleValue();
}
Program: 76461
Project: 76461
Buggy source:
/** 
 * Return true if this step did not cross the threshold.
 */
public boolean isThisStepSuccessful(){
  if (!_first) {
    _first=false;
    if (((_lastInput > _upperBound) && (_thisInput < _lowerBound)) || ((_lastInput < _lowerBound) && (_thisInput < _upperBound))) {
      _success=false;
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Return true if this step did not cross the threshold.
 */
public boolean isThisStepSuccessful(){
  if (!_first) {
    if (((_lastInput >= _upperBound) && (_thisInput <= _lowerBound)) || ((_lastInput <= _lowerBound) && (_thisInput >= _upperBound))) {
      _success=false;
      return false;
    }
  }
  _success=true;
  return true;
}
Program: 76462
Project: 76462
Buggy source:
/** 
 * Read the input receiver, if there is an event, remember the value.
 * @return true Always.
 * @exception IllegalActionException Never thrown.
 */
public boolean postfire() throws IllegalActionException {
  if (input.hasToken(0)) {
    _lasteventvalue=((DoubleToken)input.get(0)).doubleValue();
    if (DEBUG) {
      CTDirector dir=(CTDirector)getDirector();
      System.out.println("String_Node_Str" + dir.getCurrentTime());
      System.out.println("String_Node_Str" + _lasteventvalue);
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Read the input receiver, if there is an event, remember the value.
 * @return true Always.
 * @exception IllegalActionException Never thrown.
 */
public boolean postfire() throws IllegalActionException {
  return true;
}
Program: 76464
Project: 76464
Buggy source:
/** 
 * Transfer data from an input port of the container to the ports it is connected to on the inside.  The port argument must be an opaque input port.  If any channel of the input port has no data, then that channel is ignored.
 * @exception IllegalActionException If the port is not an opaqueinput port.
 */
public void transferInputs(IOPort port) throws IllegalActionException {
  if (!port.isInput() || !port.isOpaque()) {
    throw new IllegalActionException(this,port,"String_Node_Str");
  }
  Entity refine=(Entity)_controller.currentRefinement();
  IOPort p;
  Receiver rec;
  if (port.hasToken(0)) {
    try {
      Token t=port.get(0);
      p=(IOPort)_controller.getPort(port.getName());
      if (p != null) {
        rec=(p.getReceivers())[0][0];
        if (rec.hasToken()) {
          rec.get();
        }
        rec.put(t);
      }
      p=(IOPort)refine.getPort(port.getName());
      if (p != null) {
        rec=(p.getReceivers())[0][0];
        if (rec.hasToken()) {
          rec.get();
        }
        rec.put(t);
      }
    }
 catch (    NoTokenException ex) {
      throw new InternalErrorException("String_Node_Str" + ex.getMessage());
    }
  }
}

Fixed version (ground truth):
/** 
 * Transfer data from an input port of the container to the ports it is connected to on the inside.  The port argument must be an opaque input port.  If any channel of the input port has no data, then that channel is ignored.
 * @exception IllegalActionException If the port is not an opaqueinput port.
 */
public void transferInputs(IOPort port) throws IllegalActionException {
  if (!port.isInput() || !port.isOpaque()) {
    throw new IllegalActionException(this,port,"String_Node_Str");
  }
  Entity refine=(Entity)_controller.currentRefinement();
  IOPort p;
  Receiver rec;
  if (port.hasToken(0)) {
    try {
      Token t=port.get(0);
      p=(IOPort)_controller.getPort(port.getName());
      System.out.println("String_Node_Str" + ((ComponentEntity)_controller).getFullName());
      if (p != null) {
        rec=(p.getReceivers())[0][0];
        if (rec.hasToken()) {
          rec.get();
        }
        rec.put(t);
      }
      p=(IOPort)refine.getPort(port.getName());
      if (p != null) {
        rec=(p.getReceivers())[0][0];
        if (rec.hasToken()) {
          rec.get();
        }
        rec.put(t);
      }
    }
 catch (    NoTokenException ex) {
      throw new InternalErrorException("String_Node_Str" + ex.getMessage());
    }
  }
}
Program: 76465
Project: 76465
Buggy source:
/** 
 * Create receivers and then invoke the initialize() methods of all its deeply contained actors.   <p> This method should be invoked once per execution, before any iteration. It may produce output data. This method is <i>not</i> synchronized on the workspace, so the caller should be.
 * @exception IllegalActionException If the initialize() method of thecontainer or one of the deeply contained actors throws it.
 */
public void initialize() throws IllegalActionException {
  CompositeActor container=(CompositeActor)getContainer();
  if (container != null) {
    Enumeration allactors=container.deepGetEntities();
    while (allactors.hasMoreElements()) {
      Actor actor=(Actor)allactors.nextElement();
      actor.createReceivers();
      actor.initialize();
    }
  }
  System.out.println("String_Node_Str" + this.getFullName());
}

Fixed version (ground truth):
/** 
 * Create receivers and then invoke the initialize() methods of all its deeply contained actors.   <p> This method should be invoked once per execution, before any iteration. It may produce output data. This method is <i>not</i> synchronized on the workspace, so the caller should be.
 * @exception IllegalActionException If the initialize() method of thecontainer or one of the deeply contained actors throws it.
 */
public void initialize() throws IllegalActionException {
  CompositeActor container=(CompositeActor)getContainer();
  if (container != null) {
    Enumeration allactors=container.deepGetEntities();
    while (allactors.hasMoreElements()) {
      Actor actor=(Actor)allactors.nextElement();
      if (actor == _controller) {
        continue;
      }
 else {
        actor.createReceivers();
        actor.initialize();
      }
    }
    _controller.createReceivers();
    _controller.initialize();
  }
  System.out.println("String_Node_Str" + this.getFullName());
}
Program: 76466
Project: 76466
Buggy source:
/** 
 * return True, indicating that the Director is ready to fire.    Domain Directors will probably want to override this method.   Note that this is called by the container of this Director to see if the Director is ready to execute, and  should *NOT*, in general, just take the logical AND of calling prefire on all the contained actors.
 * @return True if the Director wishes to be scheduled for anotheriteration
 * @exception IllegalActionException *Deprecate* If the postfire() method of the container or one of the deeply contained actors  throws it.
 */
public boolean prefire() throws IllegalActionException {
}

Fixed version (ground truth):
/** 
 * return True, indicating that the Director is ready to fire.    Domain Directors will probably want to override this method.   Note that this is called by the container of this Director to see if the Director is ready to execute, and  should *NOT*, in general, just take the logical AND of calling prefire on all the contained actors.
 * @return True if the Director wishes to be scheduled for anotheriteration
 * @exception IllegalActionException *Deprecate* If the postfire() method of the container or one of the deeply contained actors  throws it.
 */
public boolean prefire() throws IllegalActionException {
  Actor refine=_controller.currentRefinement();
  System.out.println("String_Node_Str");
  boolean result=true;
  if (refine != null) {
    result=refine.prefire();
  }
  return result;
}
Program: 76467
Project: 76467
Buggy source:
public void initialize() throws IllegalActionException {
  try {
    setupScope();
  }
 catch (  NameDuplicationException ex) {
    throw new InvalidStateException(this,"String_Node_Str" + ex.getMessage());
  }
  if (_localVariables != null) {
    Enumeration localVars=_localVariables.getVariables();
    Variable var=null;
    while (localVars.hasMoreElements()) {
      var=(Variable)localVars.nextElement();
      var.reset();
    }
  }
  _setInputVars();
  _takenTransition=null;
  if (_initTrans != null) {
    Enumeration trs=_initTrans.elements();
    SCTransition trans;
    while (trs.hasMoreElements()) {
      trans=(SCTransition)trs.nextElement();
      if (trans.isEnabled()) {
        if (_takenTransition != null) {
          System.out.println("String_Node_Str" + "String_Node_Str");
        }
 else {
          _takenTransition=trans;
        }
      }
    }
  }
  if (_takenTransition != null) {
    _outputTriggerActions(_takenTransition.getTriggerActions());
    _updateLocalVariables(_takenTransition.getLocalVariableUpdates());
    _currentState=_takenTransition.destinationState();
  }
 else {
    _currentState=_initialState;
  }
  if (_currentState == null) {
    System.out.println("String_Node_Str");
  }
  if (currentRefinement() != null) {
    currentRefinement().createReceivers();
    currentRefinement().initialize();
    System.out.println("String_Node_Str" + ((ComponentEntity)currentRefinement()).getFullName());
  }
}

Fixed version (ground truth):
public void initialize() throws IllegalActionException {
  try {
    setupScope();
  }
 catch (  NameDuplicationException ex) {
    throw new InvalidStateException(this,"String_Node_Str" + ex.getMessage());
  }
  if (_localVariables != null) {
    Enumeration localVars=_localVariables.getVariables();
    Variable var=null;
    while (localVars.hasMoreElements()) {
      var=(Variable)localVars.nextElement();
      var.reset();
    }
  }
  _setInputVars();
  _takenTransition=null;
  if (_initTrans != null) {
    Enumeration trs=_initTrans.elements();
    SCTransition trans;
    while (trs.hasMoreElements()) {
      trans=(SCTransition)trs.nextElement();
      if (trans.isEnabled()) {
        if (_takenTransition != null) {
          System.out.println("String_Node_Str" + "String_Node_Str");
        }
 else {
          _takenTransition=trans;
        }
      }
    }
  }
  if (_takenTransition != null) {
    _outputTriggerActions(_takenTransition.getTriggerActions());
    _updateLocalVariables(_takenTransition.getLocalVariableUpdates());
    _currentState=_takenTransition.destinationState();
  }
 else {
    _currentState=_initialState;
  }
  if (_currentState == null) {
    System.out.println("String_Node_Str");
  }
  if (currentRefinement() != null) {
    System.out.println("String_Node_Str" + ((ComponentEntity)currentRefinement()).getFullName());
  }
}
Program: 76469
Project: 76469
Buggy source:
/** 
 * Convert the given actors to a directed acyclic graph. CTDynamicActors are treated as sinks. Each actor in the given enumeration is a node in the graph,  each link between a pair of actors is a edge between the corresponding nodes unless the source node is a dynamic actor. The presentance of the director and containers is not checked in this method, so the caller should check.
 * @return A graph representation of the actors.
 */
protected DirectedAcyclicGraph _toGraph(Enumeration actors){
  CTDirector dir=(CTDirector)getContainer();
  CompositeActor ca=(CompositeActor)(dir.getContainer());
  DirectedAcyclicGraph g=new DirectedAcyclicGraph();
  LinkedList actorlist=new LinkedList();
  while (actors.hasMoreElements()) {
    AtomicActor a=(AtomicActor)actors.nextElement();
    g.add(a);
    actorlist.insertLast(a);
  }
  Enumeration allactors=actorlist.elements();
  while (allactors.hasMoreElements()) {
    Actor a=(Actor)allactors.nextElement();
    if (!(a instanceof CTDynamicActor)) {
      Enumeration successors=_successors(a);
      while (successors.hasMoreElements()) {
        Actor s=(Actor)successors.nextElement();
        if (actorlist.includes(s)) {
          g.addEdge(a,s);
        }
      }
    }
  }
  return g;
}

Fixed version (ground truth):
/** 
 * Convert the given actors to a directed acyclic graph. CTDynamicActors are NOT treated as sinks. Each actor in the given enumeration is a node in the graph,  each link between a pair of actors is a edge between the corresponding nodes unless the source node is a dynamic actor. The presentance of the director and containers is not checked in this method, so the caller should check.
 * @return A graph representation of the actors.
 */
protected DirectedAcyclicGraph _toGraph(Enumeration actors){
  CTDirector dir=(CTDirector)getContainer();
  CompositeActor ca=(CompositeActor)(dir.getContainer());
  DirectedAcyclicGraph g=new DirectedAcyclicGraph();
  LinkedList actorlist=new LinkedList();
  while (actors.hasMoreElements()) {
    AtomicActor a=(AtomicActor)actors.nextElement();
    g.add(a);
    actorlist.insertLast(a);
  }
  Enumeration allactors=actorlist.elements();
  while (allactors.hasMoreElements()) {
    Actor a=(Actor)allactors.nextElement();
    Enumeration successors=_successors(a);
    while (successors.hasMoreElements()) {
      Actor s=(Actor)successors.nextElement();
      if (actorlist.includes(s)) {
        g.addEdge(a,s);
      }
    }
  }
  return g;
}
Program: 76471
Project: 76471
Buggy source:
/** 
 * Clone the actor into the specified workspace. This calls the base class and then creates new ports and parameters.
 * @param ws The workspace for the new object.
 * @return A new actor.
 */
public Object clone(Workspace ws){
  try {
    _firingCount=1;
    Expression newobj=(Expression)super.clone(ws);
    newobj.output=new TypedIOPort(this,"String_Node_Str",false,true);
    expression=new Parameter(this,"String_Node_Str",new StringToken("String_Node_Str"));
    newobj._time=new PassiveVariable(this,"String_Node_Str",new DoubleToken(0.0));
    newobj._firing=new PassiveVariable(this,"String_Node_Str",new IntToken(0));
    return newobj;
  }
 catch (  KernelException ex) {
    throw new InternalErrorException("String_Node_Str" + ex.getMessage());
  }
catch (  CloneNotSupportedException ex) {
    throw new InternalErrorException("String_Node_Str" + ex.getMessage());
  }
}

Fixed version (ground truth):
/** 
 * Clone the actor into the specified workspace. This calls the base class and then creates new ports and parameters.
 * @param ws The workspace for the new object.
 * @return A new actor.
 */
public Object clone(Workspace ws){
  try {
    _firingCount=1;
    Expression newobj=(Expression)super.clone(ws);
    newobj.output=(TypedIOPort)newobj.getPort("String_Node_Str");
    expression=(Parameter)newobj.getAttribute("String_Node_Str");
    newobj._time=(PassiveVariable)newobj.getAttribute("String_Node_Str");
    newobj._firing=(PassiveVariable)newobj.getAttribute("String_Node_Str");
    return newobj;
  }
 catch (  CloneNotSupportedException ex) {
    throw new InternalErrorException("String_Node_Str" + ex.getMessage());
  }
}
Program: 76472
Project: 76472
Buggy source:
/** 
 * Clone the actor into the specified workspace. This calls the base class and then creates new ports and parameters.
 * @param ws The workspace for the new object.
 * @return A new actor.
 */
public Object clone(Workspace ws){
  try {
    Gaussian newobj=(Gaussian)super.clone(ws);
    newobj.output=new TypedIOPort(this,"String_Node_Str",false,true);
    newobj.output.setDeclaredType(DoubleToken.class);
    newobj.mean=new Parameter(this,"String_Node_Str",new DoubleToken(0.0));
    newobj.stddev=new Parameter(this,"String_Node_Str",new DoubleToken(1.0));
    newobj.seed=new Parameter(this,"String_Node_Str",new LongToken(0));
    return newobj;
  }
 catch (  KernelException ex) {
    throw new InternalErrorException("String_Node_Str" + ex.getMessage());
  }
catch (  CloneNotSupportedException ex) {
    throw new InternalErrorException("String_Node_Str" + ex.getMessage());
  }
}

Fixed version (ground truth):
/** 
 * Clone the actor into the specified workspace. This calls the base class and then creates new ports and parameters.
 * @param ws The workspace for the new object.
 * @return A new actor.
 */
public Object clone(Workspace ws){
  try {
    Gaussian newobj=(Gaussian)super.clone(ws);
    newobj.output=(TypedIOPort)newobj.getPort("String_Node_Str");
    newobj.output.setDeclaredType(DoubleToken.class);
    newobj.mean=(Parameter)newobj.getAttribute("String_Node_Str");
    newobj.stddev=(Parameter)newobj.getAttribute("String_Node_Str");
    newobj.seed=(Parameter)newobj.getAttribute("String_Node_Str");
    return newobj;
  }
 catch (  CloneNotSupportedException ex) {
    throw new InternalErrorException("String_Node_Str" + ex.getMessage());
  }
}