Program: 180592
Project: 180592
Buggy source:
/** 
 * Evaluates any valid Epox expression which may optionally contain the use of any argument named in the <code>argNames</code> array which will be pre-declared and assigned to the associated value taken from the <code>argValues</code> array.  The expression will be evaluated once for each set of <code>argValues</code>.  The object array returned will contain the result of each of these  evaluations in order. Any functions or terminals (except the input variables) which are not  part of the built-in language, must be declared in the EpoxParser before being used here.
 * @param expression an individual representing a valid Epox expression that is to be evaluated.
 * @param argNames {@inheritDoc}
 * @param argValues {@inheritDoc}
 * @return the return values from evaluating the expression. The runtimetype of the returned Objects may vary from program to program. If the program does not return a value then this method will return an array of nulls.
 */
@Override public Object[] eval(T program,String[] argNames,Object[][] argValues) throws MalformedProgramException {
  int noParamSets=argValues.length;
  int noParams=argNames.length;
  VariableNode[] declaredVariables=new VariableNode[noParams];
  String expression=generator.getSource(program);
  Object[] results=new Object[noParamSets];
  if (expression == null) {
    throw new MalformedProgramException("String_Node_Str");
  }
 else   if (noParamSets > 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  for (int j=0; j < noParams; j++) {
    declaredVariables[j]=new VariableNode(new Variable(argNames[j],argValues[0][j]));
    parser.declare(declaredVariables[j]);
  }
  Node parseTree=parser.parse(expression);
  for (int i=0; i < noParamSets; i++) {
    Object[] paramSet=argValues[i];
    for (int j=0; j < noParams; j++) {
      declaredVariables[j].getVariable().setValue(paramSet[j]);
    }
    results[i]=parseTree.evaluate();
  }
  for (int j=0; j < noParams; j++) {
    parser.undeclare(declaredVariables[j]);
  }
  return results;
}

Fixed version (ground truth):
/** 
 * Evaluates any valid Epox expression which may optionally contain the use of any argument named in the <code>argNames</code> array which will be pre-declared and assigned to the associated value taken from the <code>argValues</code> array.  The expression will be evaluated once for each set of <code>argValues</code>.  The object array returned will contain the result of each of these  evaluations in order. Any functions or terminals (except the input variables) which are not  part of the built-in language, must be declared in the EpoxParser before being used here.
 * @param expression an individual representing a valid Epox expression that is to be evaluated.
 * @param argNames {@inheritDoc}
 * @param argValues {@inheritDoc}
 * @return the return values from evaluating the expression. The runtimetype of the returned Objects may vary from program to program. If the program does not return a value then this method will return an array of nulls.
 */
@Override public Object[] eval(T program,String[] argNames,Object[][] argValues) throws MalformedProgramException {
  int noParamSets=argValues.length;
  int noParams=argNames.length;
  VariableNode[] declaredVariables=new VariableNode[noParams];
  String expression=generator.getSource(program);
  Object[] results=new Object[noParamSets];
  if (expression == null) {
    throw new MalformedProgramException("String_Node_Str");
  }
 else   if (noParamSets <= 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  for (int j=0; j < noParams; j++) {
    declaredVariables[j]=new VariableNode(new Variable(argNames[j],argValues[0][j]));
    parser.declare(declaredVariables[j]);
  }
  Node parseTree=parser.parse(expression);
  for (int i=0; i < noParamSets; i++) {
    Object[] paramSet=argValues[i];
    for (int j=0; j < noParams; j++) {
      declaredVariables[j].getVariable().setValue(paramSet[j]);
    }
    results[i]=parseTree.evaluate();
  }
  for (int j=0; j < noParams; j++) {
    parser.undeclare(declaredVariables[j]);
  }
  return results;
}