nus-yam/ex-repair huggingface dataset:
Program: 144182
Project: 144182
Buggy source:
@Test public void testHestenesStiefelSolver(){
  double[] expectedResult=new double[]{1,1};
  System.out.println("String_Node_Str");
  NonlinearConjugateGradientSolver hestenesStiefelSolver=new NonlinearConjugateGradientSolver.Builder(new RosenbrockFunction(),new double[]{-1.2,1}).method(NonlinearConjugateGradientSolver.Method.HESTENES_STIEFEL).restartMethod(NonlinearConjugateGradientSolver.RestartMethod.GRADIENTS_ORTHOGONALITY_CHECK).build();
  double[] actualResult=hestenesStiefelSolver.solve().getArray();
  Assert.assertArrayEquals(expectedResult,actualResult,1e-2);
}

Fixed version (ground truth):
@Test public void testHestenesStiefelSolver(){
  System.out.println("String_Node_Str");
  NonlinearConjugateGradientSolver hestenesStiefelSolver=new NonlinearConjugateGradientSolver.Builder(new RosenbrockFunction(),new double[]{-1.2,1}).method(NonlinearConjugateGradientSolver.Method.HESTENES_STIEFEL).restartMethod(NonlinearConjugateGradientSolver.RestartMethod.NO_RESTART).build();
  double[] actualResult=hestenesStiefelSolver.solve().getArray();
  double[] expectedResult=new double[]{1,1};
  Assert.assertArrayEquals(expectedResult,actualResult,1e-2);
  System.out.println("String_Node_Str");
  hestenesStiefelSolver=new NonlinearConjugateGradientSolver.Builder(new RosenbrockFunction(),new double[]{-1.2,1}).method(NonlinearConjugateGradientSolver.Method.HESTENES_STIEFEL).restartMethod(NonlinearConjugateGradientSolver.RestartMethod.N_STEP).build();
  actualResult=hestenesStiefelSolver.solve().getArray();
  Assert.assertArrayEquals(expectedResult,actualResult,1e-2);
  System.out.println("String_Node_Str");
  hestenesStiefelSolver=new NonlinearConjugateGradientSolver.Builder(new RosenbrockFunction(),new double[]{-1.2,1}).method(NonlinearConjugateGradientSolver.Method.HESTENES_STIEFEL).restartMethod(NonlinearConjugateGradientSolver.RestartMethod.GRADIENTS_ORTHOGONALITY_CHECK).build();
  actualResult=hestenesStiefelSolver.solve().getArray();
  Assert.assertArrayEquals(expectedResult,actualResult,1e-2);
}
Program: 144183
Project: 144183
Buggy source:
AbstractLineSearchSolver(Builder<? extends AbstractLineSearchSolver> builder){
  super(builder);
  this.lineSearch=builder.lineSearch;
}

Fixed version (ground truth):
AbstractLineSearchSolver(Builder<? extends AbstractLineSearchSolver> builder){
  super(builder);
  this.lineSearch=builder.lineSearch;
  previousPoint=currentPoint;
}
Program: 144184
Project: 144184
Buggy source:
public void updateStepSize(){
  currentStepSize=lineSearch.computeStepSize(currentPoint,currentDirection,previousPoint,previousDirection,previousStepSize);
}

Fixed version (ground truth):
public void updateStepSize(){
  currentStepSize=lineSearch.computeStepSize(previousPoint,currentDirection,previousPreviousPoint,previousDirection,previousStepSize);
}
Program: 144185
Project: 144185
Buggy source:
@Override public void iterationUpdate(){
  previousGradient=currentGradient;
  previousDirection=currentDirection;
  updateDirection();
  previousStepSize=currentStepSize;
  updateStepSize();
  previousPoint=currentPoint;
  previousObjectiveValue=currentObjectiveValue;
  updatePoint();
  currentObjectiveValue=objective.getValue(currentPoint);
}

Fixed version (ground truth):
@Override public void iterationUpdate(){
  previousPreviousPoint=previousPoint;
  previousPoint=currentPoint;
  previousGradient=currentGradient;
  previousDirection=currentDirection;
  previousStepSize=currentStepSize;
  previousObjectiveValue=currentObjectiveValue;
  updateDirection();
  updateStepSize();
  updatePoint();
  currentObjectiveValue=objective.getValue(currentPoint);
}
Program: 144186
Project: 144186
Buggy source:
@Override public void updatePoint(){
  currentPoint=currentPoint.add(currentDirection.multiply(currentStepSize));
  if (method == Method.CYCLE_AND_JOIN_ENDPOINTS) {
    if (currentDimension == 0) {
      cycleStartPoint=cycleEndPoint;
    }
 else     if (currentDimension > numberOfDimensions - 1) {
      cycleEndPoint=currentPoint;
    }
  }
}

Fixed version (ground truth):
@Override public void updatePoint(){
  currentPoint=previousPoint.add(currentDirection.multiply(currentStepSize));
  if (method == Method.CYCLE_AND_JOIN_ENDPOINTS) {
    if (currentDimension == 0) {
      cycleStartPoint=cycleEndPoint;
    }
 else     if (currentDimension > numberOfDimensions - 1) {
      cycleEndPoint=currentPoint;
    }
  }
}
Program: 144187
Project: 144187
Buggy source:
@Override public void updateDirection(){
  currentDirection=new Vector(numberOfDimensions,0);
switch (method) {
case CYCLE:
    currentDirection.setElement(currentDimension,1);
  if (currentDimension >= numberOfDimensions - 1) {
    currentDimension=0;
  }
 else {
    currentDimension++;
  }
break;
case BACK_AND_FORTH:
if (currentDimension < numberOfDimensions) {
currentDirection.setElement(currentDimension,1);
currentDimension++;
}
 else {
currentDirection.setElement(2 * numberOfDimensions - currentDimension - 2,1);
if (currentDimension >= 2 * numberOfDimensions - 2) {
  currentDimension=1;
}
 else {
  currentDimension++;
}
}
break;
case CYCLE_AND_JOIN_ENDPOINTS:
if (!completedCycle) {
currentDirection.setElement(currentDimension,1);
if (currentDimension >= numberOfDimensions - 1) {
completedCycle=true;
currentDimension++;
}
 else {
currentDimension++;
}
}
 else {
currentDirection=cycleEndPoint.subtract(cycleStartPoint);
currentDimension=0;
completedCycle=false;
}
break;
default :
throw new NotImplementedException();
}
if (!(objective.computeValue(currentPoint.add(currentDirection.multiply(epsilon))) - currentObjectiveValue < 0)) {
currentDirection=currentDirection.multiply(-1);
}
}

Fixed version (ground truth):
@Override public void updateDirection(){
  currentDirection=new Vector(numberOfDimensions,0);
switch (method) {
case CYCLE:
    currentDirection.setElement(currentDimension,1);
  if (currentDimension >= numberOfDimensions - 1) {
    currentDimension=0;
  }
 else {
    currentDimension++;
  }
break;
case BACK_AND_FORTH:
if (currentDimension < numberOfDimensions) {
currentDirection.setElement(currentDimension,1);
currentDimension++;
}
 else {
currentDirection.setElement(2 * numberOfDimensions - currentDimension - 2,1);
if (currentDimension >= 2 * numberOfDimensions - 2) {
  currentDimension=1;
}
 else {
  currentDimension++;
}
}
break;
case CYCLE_AND_JOIN_ENDPOINTS:
if (!completedCycle) {
currentDirection.setElement(currentDimension,1);
if (currentDimension >= numberOfDimensions - 1) {
completedCycle=true;
currentDimension++;
}
 else {
currentDimension++;
}
}
 else {
currentDirection=cycleEndPoint.subtract(cycleStartPoint);
currentDimension=0;
completedCycle=false;
}
break;
default :
throw new NotImplementedException();
}
if (!(objective.computeValue(previousPoint.add(currentDirection.multiply(epsilon))) - currentObjectiveValue < 0)) {
currentDirection=currentDirection.multiply(-1);
}
}
Program: 144188
Project: 144188
Buggy source:
public Builder gradientTolerance(double gradientTolerance){
  this.gradientTolerance=gradientTolerance;
  return this;
}

Fixed version (ground truth):
public Builder<T> gradientTolerance(double gradientTolerance){
  this.gradientTolerance=gradientTolerance;
  return this;
}
Program: 144189
Project: 144189
Buggy source:
public Builder checkForObjectiveConvergence(boolean checkForObjectiveConvergence){
  this.checkForObjectiveConvergence=checkForObjectiveConvergence;
  return this;
}

Fixed version (ground truth):
public Builder<T> checkForObjectiveConvergence(boolean checkForObjectiveConvergence){
  this.checkForObjectiveConvergence=checkForObjectiveConvergence;
  return this;
}
Program: 144190
Project: 144190
Buggy source:
public Builder checkForPointConvergence(boolean checkForPointConvergence){
  this.checkForPointConvergence=checkForPointConvergence;
  return this;
}

Fixed version (ground truth):
public Builder<T> checkForPointConvergence(boolean checkForPointConvergence){
  this.checkForPointConvergence=checkForPointConvergence;
  return this;
}
Program: 144191
Project: 144191
Buggy source:
public Builder maximumNumberOfFunctionEvaluations(int maximumNumberOfFunctionEvaluations){
  this.maximumNumberOfFunctionEvaluations=maximumNumberOfFunctionEvaluations;
  return this;
}

Fixed version (ground truth):
public Builder<T> maximumNumberOfFunctionEvaluations(int maximumNumberOfFunctionEvaluations){
  this.maximumNumberOfFunctionEvaluations=maximumNumberOfFunctionEvaluations;
  return this;
}
Program: 144192
Project: 144192
Buggy source:
public Builder pointChangeTolerance(double pointChangeTolerance){
  this.pointChangeTolerance=pointChangeTolerance;
  return this;
}

Fixed version (ground truth):
public Builder<T> pointChangeTolerance(double pointChangeTolerance){
  this.pointChangeTolerance=pointChangeTolerance;
  return this;
}
Program: 144193
Project: 144193
Buggy source:
public Builder checkForGradientConvergence(boolean checkForGradientConvergence){
  this.checkForGradientConvergence=checkForGradientConvergence;
  return this;
}

Fixed version (ground truth):
public Builder<T> checkForGradientConvergence(boolean checkForGradientConvergence){
  this.checkForGradientConvergence=checkForGradientConvergence;
  return this;
}
Program: 144194
Project: 144194
Buggy source:
public Builder objectiveChangeTolerance(double objectiveChangeTolerance){
  this.objectiveChangeTolerance=objectiveChangeTolerance;
  return this;
}

Fixed version (ground truth):
public Builder<T> objectiveChangeTolerance(double objectiveChangeTolerance){
  this.objectiveChangeTolerance=objectiveChangeTolerance;
  return this;
}
Program: 144195
Project: 144195
Buggy source:
public Builder maximumNumberOfIterations(int maximumNumberOfIterations){
  this.maximumNumberOfIterations=maximumNumberOfIterations;
  return this;
}

Fixed version (ground truth):
public Builder<T> maximumNumberOfIterations(int maximumNumberOfIterations){
  this.maximumNumberOfIterations=maximumNumberOfIterations;
  return this;
}
Program: 144196
Project: 144196
Buggy source:
public ConjugateGradientSolver build() throws NonPositiveDefiniteMatrixException {
  return new ConjugateGradientSolver(this);
}

Fixed version (ground truth):
public ConjugateGradientSolver build(){
  try {
    return new ConjugateGradientSolver(this);
  }
 catch (  NonPositiveDefiniteMatrixException e) {
    e.printStackTrace();
    return null;
  }
}
Program: 144198
Project: 144198
Buggy source:
AbstractIterativeSolver(Builder<? extends AbstractIterativeSolver> builder){
  this.objective=builder.objective;
  currentPoint=new Vector(builder.initialPoint);
  currentGradient=objective.getGradient(currentPoint);
  currentObjectiveValue=objective.getValue(currentPoint);
  currentIteration=0;
}

Fixed version (ground truth):
AbstractIterativeSolver(Builder builder){
  this.objective=builder.objective;
  currentPoint=new Vector(builder.initialPoint);
  currentGradient=objective.getGradient(currentPoint);
  currentObjectiveValue=objective.getValue(currentPoint);
  currentIteration=0;
}
Program: 144199
Project: 144199
Buggy source:
/** 
 * Computes the \(L_\infty\) norm of this vector. Denoting this vector by \(\boldsymbol{x}\in\mathbb{R}^{n}\), its element at index \(i\) by \(x_i\) and its \(L_\infty\) norm by \(\|\boldsymbol{x}\|_\infty\), we have that: \[\|\boldsymbol{x}\|_\infty=\max_{1\leq i\leq n}{\left|x_i\right|}.\]
 * @return  The \(L_\infty\) norm of this vector.
 */
public double computeLInfinityNorm(){
  double lInfinityNorm=0;
  for (int i=0; i < dimension; i++) {
    lInfinityNorm=Math.max(lInfinityNorm,array[i]);
  }
  return Math.sqrt(lInfinityNorm);
}

Fixed version (ground truth):
/** 
 * Computes the \(L_\infty\) norm of this vector. Denoting this vector by \(\boldsymbol{x}\in\mathbb{R}^{n}\), its element at index \(i\) by \(x_i\) and its \(L_\infty\) norm by \(\|\boldsymbol{x}\|_\infty\), we have that: \[\|\boldsymbol{x}\|_\infty=\max_{1\leq i\leq n}{\left|x_i\right|}.\]
 * @return  The \(L_\infty\) norm of this vector.
 */
public double computeLInfinityNorm(){
  double lInfinityNorm=0;
  for (int i=0; i < dimension; i++) {
    lInfinityNorm=Math.max(lInfinityNorm,array[i]);
  }
  return lInfinityNorm;
}
Program: 144200
Project: 144200
Buggy source:
public void setM(int m){
  this.m=m;
}

Fixed version (ground truth):
public void setM(int m){
  if (method != Method.LIMITED_MEMORY_BROYDEN_FLETCHER_GOLDFARB_SHANNO) {
    this.m=1;
  }
 else {
    this.m=m;
  }
  s=new RealVector[m];
  y=new RealVector[m];
}
Program: 144201
Project: 144201
Buggy source:
@Test public void testCentralDifferenceHessianApproximationGivenGradient(){
  AbstractFunction function=new RosenbrockFunction();
  DerivativesApproximation derivativesApproximation=new DerivativesApproximation(function,DerivativesApproximationMethod.CENTRAL_DIFFERENCE);
  RealVector point=new ArrayRealVector(new double[]{-1.2,1});
  double[][] actualResultTemp=derivativesApproximation.approximateHessianGivenGradient(point).getData();
  double[][] expectedResultTemp=function.getHessian(point).getData();
  double[] actualResult=new double[actualResultTemp.length * actualResultTemp[0].length];
  double[] expectedResult=new double[expectedResultTemp.length * expectedResultTemp[0].length];
  for (int i=0; i < actualResultTemp.length; i++) {
    for (int j=0; j < actualResultTemp[0].length; j++) {
      actualResult[i * actualResultTemp.length + j]=actualResultTemp[i][j];
      expectedResult[i * expectedResultTemp.length + j]=expectedResultTemp[i][j];
    }
  }
  Assert.assertArrayEquals(expectedResult,actualResult,1e-8);
}

Fixed version (ground truth):
@Test public void testCentralDifferenceHessianApproximationGivenGradient(){
  AbstractFunction function=new RosenbrockFunction();
  DerivativesApproximation derivativesApproximation=new DerivativesApproximation(function,DerivativesApproximationMethod.CENTRAL_DIFFERENCE);
  RealVector point=new ArrayRealVector(new double[]{-1.2,1});
  double[][] actualResultTemp=derivativesApproximation.approximateHessianGivenGradient(point).getData();
  double[][] expectedResultTemp=function.getHessian(point).getData();
  double[] actualResult=new double[actualResultTemp.length * actualResultTemp[0].length];
  double[] expectedResult=new double[expectedResultTemp.length * expectedResultTemp[0].length];
  for (int i=0; i < actualResultTemp.length; i++) {
    for (int j=0; j < actualResultTemp[0].length; j++) {
      actualResult[i * actualResultTemp[0].length + j]=actualResultTemp[i][j];
      expectedResult[i * expectedResultTemp[0].length + j]=expectedResultTemp[i][j];
    }
  }
  Assert.assertArrayEquals(expectedResult,actualResult,1e-8);
}
Program: 144202
Project: 144202
Buggy source:
@Test public void testCentralDifferenceHessianApproximation(){
  AbstractFunction function=new RosenbrockFunction();
  DerivativesApproximation derivativesApproximation=new DerivativesApproximation(function,DerivativesApproximationMethod.CENTRAL_DIFFERENCE);
  RealVector point=new ArrayRealVector(new double[]{-1.2,1});
  double[][] actualResultTemp=derivativesApproximation.approximateHessian(point).getData();
  double[][] expectedResultTemp=function.getHessian(point).getData();
  double[] actualResult=new double[actualResultTemp.length * actualResultTemp[0].length];
  double[] expectedResult=new double[expectedResultTemp.length * expectedResultTemp[0].length];
  for (int i=0; i < actualResultTemp.length; i++) {
    for (int j=0; j < actualResultTemp[0].length; j++) {
      actualResult[i * actualResultTemp.length + j]=actualResultTemp[i][j];
      expectedResult[i * expectedResultTemp.length + j]=expectedResultTemp[i][j];
    }
  }
  Assert.assertArrayEquals(expectedResult,actualResult,1e-3);
}

Fixed version (ground truth):
@Test public void testCentralDifferenceHessianApproximation(){
  AbstractFunction function=new RosenbrockFunction();
  DerivativesApproximation derivativesApproximation=new DerivativesApproximation(function,DerivativesApproximationMethod.CENTRAL_DIFFERENCE);
  RealVector point=new ArrayRealVector(new double[]{-1.2,1});
  double[][] actualResultTemp=derivativesApproximation.approximateHessian(point).getData();
  double[][] expectedResultTemp=function.getHessian(point).getData();
  double[] actualResult=new double[actualResultTemp.length * actualResultTemp[0].length];
  double[] expectedResult=new double[expectedResultTemp.length * expectedResultTemp[0].length];
  for (int i=0; i < actualResultTemp.length; i++) {
    for (int j=0; j < actualResultTemp[0].length; j++) {
      actualResult[i * actualResultTemp[0].length + j]=actualResultTemp[i][j];
      expectedResult[i * expectedResultTemp[0].length + j]=expectedResultTemp[i][j];
    }
  }
  Assert.assertArrayEquals(expectedResult,actualResult,1e-3);
}
Program: 144203
Project: 144203
Buggy source:
@Test public void testForwardDifferenceHessianApproximationGivenGradient(){
  AbstractFunction function=new RosenbrockFunction();
  DerivativesApproximation derivativesApproximation=new DerivativesApproximation(function,DerivativesApproximationMethod.FORWARD_DIFFERENCE);
  RealVector point=new ArrayRealVector(new double[]{-1.2,1});
  double[][] actualResultTemp=derivativesApproximation.approximateHessianGivenGradient(point).getData();
  double[][] expectedResultTemp=function.getHessian(point).getData();
  double[] actualResult=new double[actualResultTemp.length * actualResultTemp[0].length];
  double[] expectedResult=new double[expectedResultTemp.length * expectedResultTemp[0].length];
  for (int i=0; i < actualResultTemp.length; i++) {
    for (int j=0; j < actualResultTemp[0].length; j++) {
      actualResult[i * actualResultTemp.length + j]=actualResultTemp[i][j];
      expectedResult[i * expectedResultTemp.length + j]=expectedResultTemp[i][j];
    }
  }
  Assert.assertArrayEquals(expectedResult,actualResult,1e-4);
}

Fixed version (ground truth):
@Test public void testForwardDifferenceHessianApproximationGivenGradient(){
  AbstractFunction function=new RosenbrockFunction();
  DerivativesApproximation derivativesApproximation=new DerivativesApproximation(function,DerivativesApproximationMethod.FORWARD_DIFFERENCE);
  RealVector point=new ArrayRealVector(new double[]{-1.2,1});
  double[][] actualResultTemp=derivativesApproximation.approximateHessianGivenGradient(point).getData();
  double[][] expectedResultTemp=function.getHessian(point).getData();
  double[] actualResult=new double[actualResultTemp.length * actualResultTemp[0].length];
  double[] expectedResult=new double[expectedResultTemp.length * expectedResultTemp[0].length];
  for (int i=0; i < actualResultTemp.length; i++) {
    for (int j=0; j < actualResultTemp[0].length; j++) {
      actualResult[i * actualResultTemp[0].length + j]=actualResultTemp[i][j];
      expectedResult[i * expectedResultTemp[0].length + j]=expectedResultTemp[i][j];
    }
  }
  Assert.assertArrayEquals(expectedResult,actualResult,1e-4);
}
Program: 144204
Project: 144204
Buggy source:
@Test public void testForwardDifferenceHessianApproximation(){
  AbstractFunction function=new RosenbrockFunction();
  DerivativesApproximation derivativesApproximation=new DerivativesApproximation(function,DerivativesApproximationMethod.FORWARD_DIFFERENCE);
  RealVector point=new ArrayRealVector(new double[]{-1.2,1});
  double[][] actualResultTemp=derivativesApproximation.approximateHessian(point).getData();
  double[][] expectedResultTemp=function.getHessian(point).getData();
  double[] actualResult=new double[actualResultTemp.length * actualResultTemp[0].length];
  double[] expectedResult=new double[expectedResultTemp.length * expectedResultTemp[0].length];
  for (int i=0; i < actualResultTemp.length; i++) {
    for (int j=0; j < actualResultTemp[0].length; j++) {
      actualResult[i * actualResultTemp.length + j]=actualResultTemp[i][j];
      expectedResult[i * expectedResultTemp.length + j]=expectedResultTemp[i][j];
    }
  }
  Assert.assertArrayEquals(expectedResult,actualResult,1e2);
}

Fixed version (ground truth):
@Test public void testForwardDifferenceHessianApproximation(){
  AbstractFunction function=new RosenbrockFunction();
  DerivativesApproximation derivativesApproximation=new DerivativesApproximation(function,DerivativesApproximationMethod.FORWARD_DIFFERENCE);
  RealVector point=new ArrayRealVector(new double[]{-1.2,1});
  double[][] actualResultTemp=derivativesApproximation.approximateHessian(point).getData();
  double[][] expectedResultTemp=function.getHessian(point).getData();
  double[] actualResult=new double[actualResultTemp.length * actualResultTemp[0].length];
  double[] expectedResult=new double[expectedResultTemp.length * expectedResultTemp[0].length];
  for (int i=0; i < actualResultTemp.length; i++) {
    for (int j=0; j < actualResultTemp[0].length; j++) {
      actualResult[i * actualResultTemp[0].length + j]=actualResultTemp[i][j];
      expectedResult[i * expectedResultTemp[0].length + j]=expectedResultTemp[i][j];
    }
  }
  Assert.assertArrayEquals(expectedResult,actualResult,1e2);
}
Program: 144205
Project: 144205
Buggy source:
public AbstractLineSearchSolver(AbstractFunction objective,double[] initialPoint){
  super(objective,initialPoint);
  if (objective instanceof QuadraticFunction) {
    lineSearch=new ExactLineSearch((QuadraticFunction)objective);
  }
 else {
    lineSearch=new StrongWolfeInterpolationLineSearch(objective,1e-4,0.9,10);
    ((StrongWolfeInterpolationLineSearch)lineSearch).setStepSizeInitializationMethod(StepSizeInitializationMethod.CONSERVE_FIRST_ORDER_CHANGE);
  }
}

Fixed version (ground truth):
public AbstractLineSearchSolver(AbstractFunction objective,double[] initialPoint){
  super(objective,initialPoint);
  if (objective instanceof QuadraticFunction) {
    RealMatrix quadraticFactorMatrix=((QuadraticFunction)objective).getA();
    if (MatrixUtils.isSymmetric(quadraticFactorMatrix,1e-8)) {
      DecompositionSolver choleskyDecompositionSolver=new CholeskyDecomposition(quadraticFactorMatrix).getSolver();
      if (choleskyDecompositionSolver.isNonSingular()) {
        lineSearch=new ExactLineSearch((QuadraticFunction)objective);
        return;
      }
    }
  }
  lineSearch=new StrongWolfeInterpolationLineSearch(objective,1e-4,0.9,10);
  ((StrongWolfeInterpolationLineSearch)lineSearch).setStepSizeInitializationMethod(StepSizeInitializationMethod.CONSERVE_FIRST_ORDER_CHANGE);
}
Program: 144206
Project: 144206
Buggy source:
public NonlinearConjugateGradientSolver(AbstractFunction objective,double[] initialPoint){
  super(objective,initialPoint);
  setCheckForPointConvergence(false);
  setCheckForObjectiveConvergence(false);
  currentDirection=currentGradient.mapMultiply(-1);
  if (objective instanceof QuadraticFunction) {
    lineSearch=new ExactLineSearch((QuadraticFunction)objective);
  }
 else {
    lineSearch=new StrongWolfeInterpolationLineSearch(objective,1e-4,0.9,10);
    ((StrongWolfeInterpolationLineSearch)lineSearch).setStepSizeInitializationMethod(StepSizeInitializationMethod.CONSERVE_FIRST_ORDER_CHANGE);
  }
}

Fixed version (ground truth):
public NonlinearConjugateGradientSolver(AbstractFunction objective,double[] initialPoint){
  super(objective,initialPoint);
  setCheckForPointConvergence(false);
  setCheckForObjectiveConvergence(false);
  currentDirection=currentGradient.mapMultiply(-1);
  if (objective instanceof QuadraticFunction) {
    RealMatrix quadraticFactorMatrix=((QuadraticFunction)objective).getA();
    if (MatrixUtils.isSymmetric(quadraticFactorMatrix,1e-8)) {
      DecompositionSolver choleskyDecompositionSolver=new CholeskyDecomposition(quadraticFactorMatrix).getSolver();
      if (choleskyDecompositionSolver.isNonSingular()) {
        lineSearch=new ExactLineSearch((QuadraticFunction)objective);
        return;
      }
    }
  }
  lineSearch=new StrongWolfeInterpolationLineSearch(objective,1e-4,0.9,10);
  ((StrongWolfeInterpolationLineSearch)lineSearch).setStepSizeInitializationMethod(StepSizeInitializationMethod.CONSERVE_FIRST_ORDER_CHANGE);
}
Program: 144208
Project: 144208
Buggy source:
public AbstractLineSearchSolver(AbstractFunction objective,double[] initialPoint){
  this.objective=objective;
  this.currentPoint=new ArrayRealVector(initialPoint);
  currentObjectiveValue=objective.getValue(currentPoint);
  currentIteration=0;
  if (objective instanceof QuadraticFunction) {
    this.lineSearch=new ExactLineSearch((QuadraticFunction)objective);
  }
 else {
    this.lineSearch=new StrongWolfeInterpolationLineSearch(objective,StepSizeInitializationMethod.CONSERVE_FIRST_ORDER_CHANGE,1e-4,0.9,10);
  }
}

Fixed version (ground truth):
public AbstractLineSearchSolver(AbstractFunction objective,double[] initialPoint){
  this.objective=objective;
  this.currentPoint=new ArrayRealVector(initialPoint);
  currentObjectiveValue=objective.getValue(currentPoint);
  currentGradient=objective.getGradient(currentPoint);
  currentIteration=0;
  if (objective instanceof QuadraticFunction) {
    this.lineSearch=new ExactLineSearch((QuadraticFunction)objective);
  }
 else {
    this.lineSearch=new StrongWolfeInterpolationLineSearch(objective,StepSizeInitializationMethod.CONSERVE_FIRST_ORDER_CHANGE,1e-4,0.9,10);
  }
}
Program: 144209
Project: 144209
Buggy source:
@Override public void iterationUpdate(){
  previousGradient=currentGradient;
  previousDirection=currentDirection;
  updateDirection();
  if (currentGradient.getNorm() <= gradientTolerance) {
    return;
  }
  previousStepSize=currentStepSize;
  updateStepSize();
  previousPoint=currentPoint;
  previousObjectiveValue=currentObjectiveValue;
  updatePoint();
  currentObjectiveValue=objective.getValue(currentPoint);
}

Fixed version (ground truth):
@Override public void iterationUpdate(){
  previousGradient=currentGradient;
  previousDirection=currentDirection;
  updateDirection();
  previousStepSize=currentStepSize;
  updateStepSize();
  previousPoint=currentPoint;
  previousObjectiveValue=currentObjectiveValue;
  updatePoint();
  currentObjectiveValue=objective.getValue(currentPoint);
}
Program: 144210
Project: 144210
Buggy source:
public NonlinearConjugateGradientSolver(AbstractFunction objective,double[] initialPoint,NonlinearConjugateGradientMethod method,NonlinearConjugateGradientRestartMethod restartMethod){
  this.objective=objective;
  this.method=method;
  this.restartMethod=restartMethod;
  currentPoint=new ArrayRealVector(initialPoint);
  currentGradient=objective.getGradient(currentPoint);
  currentDirection=currentGradient.mapMultiply(-1);
  currentObjectiveValue=objective.getValue(currentPoint);
  currentIteration=0;
  checkForPointConvergence=false;
  checkForObjectiveConvergence=false;
  if (objective instanceof QuadraticFunction) {
    this.lineSearch=new ExactLineSearch((QuadraticFunction)objective);
  }
 else {
    this.lineSearch=new StrongWolfeInterpolationLineSearch(objective,StepSizeInitializationMethod.CONSERVE_FIRST_ORDER_CHANGE,1e-4,0.1,10);
  }
}

Fixed version (ground truth):
public NonlinearConjugateGradientSolver(AbstractFunction objective,double[] initialPoint,NonlinearConjugateGradientMethod method,NonlinearConjugateGradientRestartMethod restartMethod){
  this.objective=objective;
  this.method=method;
  this.restartMethod=restartMethod;
  this.setCheckForPointConvergence(false);
  this.setCheckForObjectiveConvergence(false);
  currentPoint=new ArrayRealVector(initialPoint);
  currentGradient=objective.getGradient(currentPoint);
  currentDirection=currentGradient.mapMultiply(-1);
  currentObjectiveValue=objective.getValue(currentPoint);
  currentIteration=0;
  if (objective instanceof QuadraticFunction) {
    this.lineSearch=new ExactLineSearch((QuadraticFunction)objective);
  }
 else {
    this.lineSearch=new StrongWolfeInterpolationLineSearch(objective,StepSizeInitializationMethod.CONSERVE_FIRST_ORDER_CHANGE,1e-4,0.1,10);
  }
}
Program: 144211
Project: 144211
Buggy source:
public RealVector computeGradient(RealVector point){
  return derivativesApproximation.approximateGradient(point);
}

Fixed version (ground truth):
public RealVector computeGradient(RealVector point){
  if (computeGradientMethodOverridden) {
    computeGradientMethodOverridden=false;
  }
  return derivativesApproximation.approximateGradient(point);
}
Program: 144212
Project: 144212
Buggy source:
public RealMatrix computeHessian(RealVector point){
  boolean computeGradientMethodOverridden=false;
  try {
    computeGradientMethodOverridden=this.getClass().getMethod("String_Node_Str",RealVector.class).getDeclaringClass() != AbstractFunction.class;
  }
 catch (  NoSuchMethodException e) {
    e.printStackTrace();
  }
  if (computeGradientMethodOverridden) {
    return derivativesApproximation.approximateHessianGivenGradient(point);
  }
 else {
    return derivativesApproximation.approximateHessian(point);
  }
}

Fixed version (ground truth):
public RealMatrix computeHessian(RealVector point){
  if (computeGradientMethodOverridden) {
    return derivativesApproximation.approximateHessianGivenGradient(point);
  }
 else {
    return derivativesApproximation.approximateHessian(point);
  }
}
Program: 144213
Project: 144213
Buggy source:
@Test public void testLogisticRegression(){
  String filename="String_Node_Str";
  TrainingData data=DataPreprocessing.parseLabeledDataFromCSVFile(filename);
  LogisticRegression classifier=new LogisticRegression(data.getData(),data.getLabels());
  classifier.train();
  double[] actualPredictionsProbabilities=classifier.predict(new double[][]{{3,14,35,51},{3,13,35,50},{2,16,34,48},{2,17,34,54},{2,15,37,53},{19,61,28,74},{22,58,30,65},{19,53,27,64},{20,50,25,57},{24,51,28,58}});
  int[] actualPredictions=new int[actualPredictionsProbabilities.length];
  for (int i=0; i < actualPredictions.length; i++) {
    actualPredictions[i]=actualPredictionsProbabilities[i] >= 0.5 ? 1 : 0;
  }
  int[] expectedPredictions=new int[]{0,0,0,0,0,1,1,1,1,1};
  Assert.assertArrayEquals(expectedPredictions,actualPredictions);
}

Fixed version (ground truth):
@Test public void testLogisticRegression(){
  String filename=LogisticRegressionTest.class.getResource("String_Node_Str").getPath();
  TrainingData data=DataPreprocessing.parseLabeledDataFromCSVFile(filename);
  LogisticRegression classifier=new LogisticRegression(data.getData(),data.getLabels());
  classifier.train();
  double[] actualPredictionsProbabilities=classifier.predict(new double[][]{{3,14,35,51},{3,13,35,50},{2,16,34,48},{2,17,34,54},{2,15,37,53},{19,61,28,74},{22,58,30,65},{19,53,27,64},{20,50,25,57},{24,51,28,58}});
  int[] actualPredictions=new int[actualPredictionsProbabilities.length];
  for (int i=0; i < actualPredictions.length; i++) {
    actualPredictions[i]=actualPredictionsProbabilities[i] >= 0.5 ? 1 : 0;
  }
  int[] expectedPredictions=new int[]{0,0,0,0,0,1,1,1,1,1};
  Assert.assertArrayEquals(expectedPredictions,actualPredictions);
}
Program: 144214
Project: 144214
Buggy source:
public boolean checkTerminationConditions(){
  if (currentIteration > 0) {
    pointChange=currentPoint.subtract(previousPoint).getNorm();
    pointConverged=pointChange <= pointChangeTolerance;
    objectiveChange=Math.abs((previousObjectiveValue - currentObjectiveValue) / previousObjectiveValue);
    objectiveConverged=objectiveChange <= objectiveChangeTolerance;
    if (this instanceof NonlinearConjugateGradientSolver) {
      gradientNorm=Math.abs(currentGradient.getMaxValue()) / (1 + Math.abs(currentObjectiveValue));
      gradientConverged=gradientNorm <= gradientTolerance;
    }
 else {
      gradientNorm=currentDirection.getNorm();
      gradientConverged=gradientNorm <= gradientTolerance;
    }
    return (checkForPointConvergence && pointConverged) || (checkForObjectiveConvergence && objectiveConverged) || (checkForGradientConvergence && gradientConverged);
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
public boolean checkTerminationConditions(){
  if (currentIteration > 0) {
    pointChange=currentPoint.subtract(previousPoint).getNorm();
    pointConverged=pointChange <= pointChangeTolerance;
    objectiveChange=Math.abs((previousObjectiveValue - currentObjectiveValue) / previousObjectiveValue);
    objectiveConverged=objectiveChange <= objectiveChangeTolerance;
    if (this instanceof NonlinearConjugateGradientSolver) {
      gradientNorm=Math.abs(currentGradient.getMaxValue()) / (1 + Math.abs(currentObjectiveValue));
      gradientConverged=gradientNorm <= gradientTolerance;
    }
 else {
      gradientNorm=currentGradient.getNorm();
      gradientConverged=gradientNorm <= gradientTolerance;
    }
    return (checkForPointConvergence && pointConverged) || (checkForObjectiveConvergence && objectiveConverged) || (checkForGradientConvergence && gradientConverged);
  }
 else {
    return false;
  }
}
Program: 144215
Project: 144215
Buggy source:
/** 
 * {@inheritDoc}
 */
public double performLineSearch(RealVector point,RealVector direction){
  double objectiveValueAtCurrentPoint=objective.computeValue(point);
  RealVector objectiveGradientAtCurrentPoint=objective.computeGradient(point);
  double currentStepSize=initialStepSize;
  while (!LineSearchConditions.checkArmijoCondition(objective,point,direction,initialStepSize,c,objectiveValueAtCurrentPoint,objectiveGradientAtCurrentPoint)) {
    currentStepSize*=contraptionFactor;
  }
  return currentStepSize;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
public double performLineSearch(RealVector point,RealVector direction){
  double objectiveValueAtCurrentPoint=objective.computeValue(point);
  RealVector objectiveGradientAtCurrentPoint=objective.computeGradient(point);
  double currentStepSize=initialStepSize;
  while (!LineSearchConditions.checkArmijoCondition(objective,point,direction,currentStepSize,c,objectiveValueAtCurrentPoint,objectiveGradientAtCurrentPoint)) {
    currentStepSize*=contraptionFactor;
  }
  return currentStepSize;
}
Program: 144216
Project: 144216
Buggy source:
private void performQuadraticInterpolation(RealVector currentPoint,RealVector currentDirection,double objectiveValueAtCurrentPoint,double dotProductOfObjectiveGradientAndDirection){
  RealVector pointWithA0=currentPoint.add(currentDirection.mapMultiply(mostRecentStepSizes[0]));
  double phiA0=objectiveFunction.computeValue(pointWithA0);
  mostRecentStepSizes[1]=mostRecentStepSizes[0];
  mostRecentStepSizes[0]=-dotProductOfObjectiveGradientAndDirection * Math.pow(mostRecentStepSizes[1],2) / (2 * (phiA0 - objectiveValueAtCurrentPoint - mostRecentStepSizes[1] * dotProductOfObjectiveGradientAndDirection));
}

Fixed version (ground truth):
private void performQuadraticInterpolation(RealVector currentPoint,RealVector currentDirection,double phi0,double phiPrime0){
  double a0=mostRecentStepSizes[0];
  double phiA0=objectiveFunction.computeValue(currentPoint.add(currentDirection.mapMultiply(a0)));
  mostRecentStepSizes[1]=mostRecentStepSizes[0];
  mostRecentStepSizes[0]=-phiPrime0 * Math.pow(a0,2) / (2 * (phiA0 - phi0 - a0 * phiPrime0));
  if (Math.abs(mostRecentStepSizes[0] - mostRecentStepSizes[1]) <= MINIMUM_STEP_SIZE_CHANGE_THRESHOLD || mostRecentStepSizes[0] / mostRecentStepSizes[1] <= MINIMUM_STEP_SIZE_RATIO_THRESHOLD) {
    mostRecentStepSizes[0]=mostRecentStepSizes[1] / 2;
  }
}
Program: 144217
Project: 144217
Buggy source:
public ArmijoInterpolationLineSearch(Function objectiveFunction,StepSizeInitializationMethod stepSizeInitializationMethod,double c,double initialStepSize){
  super(objectiveFunction,stepSizeInitializationMethod,initialStepSize);
  Preconditions.checkArgument(c > 0 && c < 1);
  Preconditions.checkArgument(initialStepSize > 0);
  this.c=c;
  mostRecentStepSizes=new double[2];
}

Fixed version (ground truth):
public ArmijoInterpolationLineSearch(Function objectiveFunction,StepSizeInitializationMethod stepSizeInitializationMethod,double C,double initialStepSize){
  super(objectiveFunction,stepSizeInitializationMethod,initialStepSize);
  Preconditions.checkArgument(C > 0 && C < 1);
  Preconditions.checkArgument(initialStepSize > 0);
  this.C=C;
  mostRecentStepSizes=new double[2];
}
Program: 144218
Project: 144218
Buggy source:
private void performCubicInterpolation(RealVector currentPoint,RealVector currentDirection,double objectiveValueAtCurrentPoint,double dotProductOfObjectiveGradientAndDirection){
  double previousStepSize=mostRecentStepSizes[0];
  double a0=mostRecentStepSizes[1];
  double a1=mostRecentStepSizes[0];
  double a0_squared=Math.pow(a0,2);
  double a1_squared=Math.pow(a1,2);
  double a0_cubed=Math.pow(a0,3);
  double a1_cubed=Math.pow(a1,3);
  RealVector pointWithA0=currentPoint.add(currentDirection.mapMultiply(a0));
  RealVector pointWithA1=currentPoint.add(currentDirection.mapMultiply(a1));
  double phiA0=objectiveFunction.computeValue(pointWithA0);
  double phiA1=objectiveFunction.computeValue(pointWithA1);
  double denominator=a0_squared * a1_squared * (a1 - a0);
  double a=(a0_squared * (phiA1 - objectiveValueAtCurrentPoint - a1 * dotProductOfObjectiveGradientAndDirection) - a1_squared * (phiA0 - objectiveValueAtCurrentPoint - a0 * dotProductOfObjectiveGradientAndDirection)) / denominator;
  double b=(-a0_cubed * (phiA1 - objectiveValueAtCurrentPoint - a1 * dotProductOfObjectiveGradientAndDirection) + a1_cubed * (phiA0 - objectiveValueAtCurrentPoint - a0 * dotProductOfObjectiveGradientAndDirection)) / denominator;
  mostRecentStepSizes[0]=-(b - Math.sqrt(Math.pow(b,2) - 3 * a * dotProductOfObjectiveGradientAndDirection)) / (3 * a);
  mostRecentStepSizes[1]=previousStepSize;
  if (Math.abs(mostRecentStepSizes[0] - mostRecentStepSizes[1]) <= 1e-3 || mostRecentStepSizes[0] / mostRecentStepSizes[1] <= 1e-1) {
    mostRecentStepSizes[0]=mostRecentStepSizes[1] / 2;
  }
}

Fixed version (ground truth):
private void performCubicInterpolation(RealVector currentPoint,RealVector currentDirection,double phi0,double phiPrime0){
  double previousStepSize=mostRecentStepSizes[0];
  double a0=mostRecentStepSizes[1];
  double a1=mostRecentStepSizes[0];
  double a0Sq=Math.pow(a0,2);
  double a1Sq=Math.pow(a1,2);
  double a0Cub=Math.pow(a0,3);
  double a1Cub=Math.pow(a1,3);
  double phiA0=objectiveFunction.computeValue(currentPoint.add(currentDirection.mapMultiply(a0)));
  double phiA1=objectiveFunction.computeValue(currentPoint.add(currentDirection.mapMultiply(a1)));
  double denominator=a0Sq * a1Sq * (a1 - a0);
  double a=(a0Sq * (phiA1 - phi0 - a1 * phiPrime0) - a1Sq * (phiA0 - phi0 - a0 * phiPrime0)) / denominator;
  double b=(-a0Cub * (phiA1 - phi0 - a1 * phiPrime0) + a1Cub * (phiA0 - phi0 - a0 * phiPrime0)) / denominator;
  mostRecentStepSizes[0]=-(b - Math.sqrt(Math.pow(b,2) - 3 * a * phiPrime0)) / (3 * a);
  mostRecentStepSizes[1]=previousStepSize;
  if (Math.abs(mostRecentStepSizes[0] - mostRecentStepSizes[1]) <= MINIMUM_STEP_SIZE_CHANGE_THRESHOLD || mostRecentStepSizes[0] / mostRecentStepSizes[1] <= MINIMUM_STEP_SIZE_RATIO_THRESHOLD) {
    mostRecentStepSizes[0]=mostRecentStepSizes[1] / 2;
  }
}
Program: 144219
Project: 144219
Buggy source:
public void performLineSearch(RealVector currentPoint,RealVector currentDirection){
  double objectiveValueAtCurrentPoint=objectiveFunction.computeValue(currentPoint);
  RealVector objectiveGradientAtCurrentPoint=objectiveFunction.computeGradient(currentPoint);
  double dotProductOfObjectiveGradientAndDirection=objectiveGradientAtCurrentPoint.dotProduct(currentDirection);
  mostRecentStepSizes[0]=currentStepSize;
  int iterationNumber=0;
  while (!LineSearchConditions.checkArmijoCondition(objectiveFunction,currentPoint,currentDirection,mostRecentStepSizes[0],c,objectiveValueAtCurrentPoint,objectiveGradientAtCurrentPoint)) {
    if (iterationNumber == 0) {
      performQuadraticInterpolation(currentPoint,currentDirection,objectiveValueAtCurrentPoint,dotProductOfObjectiveGradientAndDirection);
    }
 else {
      performCubicInterpolation(currentPoint,currentDirection,objectiveValueAtCurrentPoint,dotProductOfObjectiveGradientAndDirection);
    }
    iterationNumber++;
    if (iterationNumber >= 10) {
      break;
    }
  }
  currentStepSize=mostRecentStepSizes[0];
}

Fixed version (ground truth):
public void performLineSearch(RealVector currentPoint,RealVector currentDirection){
  double objectiveValueAtCurrentPoint=objectiveFunction.computeValue(currentPoint);
  RealVector objectiveGradientAtCurrentPoint=objectiveFunction.computeGradient(currentPoint);
  double dotProductOfObjectiveGradientAndDirection=objectiveGradientAtCurrentPoint.dotProduct(currentDirection);
  mostRecentStepSizes[0]=currentStepSize;
  boolean firstIteration=true;
  while (!LineSearchConditions.checkArmijoCondition(objectiveFunction,currentPoint,currentDirection,mostRecentStepSizes[0],C,objectiveValueAtCurrentPoint,objectiveGradientAtCurrentPoint)) {
    if (firstIteration) {
      performQuadraticInterpolation(currentPoint,currentDirection,objectiveValueAtCurrentPoint,dotProductOfObjectiveGradientAndDirection);
      firstIteration=false;
    }
 else {
      performCubicInterpolation(currentPoint,currentDirection,objectiveValueAtCurrentPoint,dotProductOfObjectiveGradientAndDirection);
    }
  }
  currentStepSize=mostRecentStepSizes[0];
}
Program: 144220
Project: 144220
Buggy source:
private void hook2(Class<?> clazz){
  XposedBridge.hookAllMethods(clazz,"String_Node_Str",new XC_MethodHook(){
    @Override protected void afterHookedMethod(    MethodHookParam param) throws Throwable {
      String result=((String)param.getResult()).replaceAll("String_Node_Str","String_Node_Str");
      if (phoneNumber != null && !"String_Node_Str".equals(phoneNumber)) {
        result=phoneNumber + "String_Node_Str" + result;
      }
      if (phoneName != null && !"String_Node_Str".equals(phoneName)) {
        result=phoneName + "String_Node_Str" + result;
      }
      param.setResult(result);
    }
  }
);
}

Fixed version (ground truth):
private void hook2(Class<?> clazz){
  XposedBridge.hookAllMethods(clazz,"String_Node_Str",new XC_MethodHook(){
    @Override protected void afterHookedMethod(    MethodHookParam param) throws Throwable {
      String result=((String)param.getResult()).replaceAll("String_Node_Str","String_Node_Str");
      if (phoneNumber != null && !"String_Node_Str".equals(phoneNumber)) {
        result=phoneNumber.replaceAll("String_Node_Str","String_Node_Str") + "String_Node_Str" + result;
      }
      if (phoneName != null && !"String_Node_Str".equals(phoneName)) {
        result=phoneName + "String_Node_Str" + result;
      }
      param.setResult(result);
    }
  }
);
}
Program: 144221
Project: 144221
Buggy source:
private void hook1(Class<?> clazz){
  XposedBridge.hookAllMethods(clazz,"String_Node_Str",new XC_MethodHook(){
    @Override protected void afterHookedMethod(    MethodHookParam param) throws Throwable {
      Object callRecorder=mCallRecorder.get(mApp.get(param.thisObject));
      if ((Boolean)XposedHelpers.callMethod(callRecorder,"String_Node_Str")) {
        return;
      }
      CallManager cm=(CallManager)mCM.get(param.thisObject);
      Call.State state=cm.getActiveFgCallState();
      if (state == Call.State.ACTIVE) {
        XposedHelpers.callMethod(callRecorder,"String_Node_Str");
      }
 else       if (state == Call.State.ALERTING || state == Call.State.INCOMING || state == Call.State.WAITING) {
        CallerInfo callerInfo=(CallerInfo)XposedHelpers.callMethod(param.thisObject,"String_Node_Str",XposedHelpers.callMethod(param.thisObject,"String_Node_Str",cm.getActiveFgCall()));
        phoneName=callerInfo.name;
        phoneNumber=callerInfo.phoneNumber.startsWith("String_Node_Str") ? callerInfo.phoneNumber.substring(4) : callerInfo.phoneNumber;
      }
    }
  }
);
}

Fixed version (ground truth):
private void hook1(Class<?> clazz){
  XposedBridge.hookAllMethods(clazz,"String_Node_Str",new XC_MethodHook(){
    @Override protected void afterHookedMethod(    MethodHookParam param) throws Throwable {
      Object callRecorder=mCallRecorder.get(mApp.get(param.thisObject));
      if ((Boolean)XposedHelpers.callMethod(callRecorder,"String_Node_Str")) {
        return;
      }
      CallManager cm=(CallManager)mCM.get(param.thisObject);
      Call.State state=cm.getActiveFgCallState();
      if (state == Call.State.ACTIVE) {
        CallerInfo callerInfo=(CallerInfo)XposedHelpers.callMethod(param.thisObject,"String_Node_Str",XposedHelpers.callMethod(param.thisObject,"String_Node_Str",cm.getActiveFgCall()));
        phoneName=callerInfo.name;
        phoneNumber=callerInfo.phoneNumber.startsWith("String_Node_Str") ? callerInfo.phoneNumber.substring(4) : callerInfo.phoneNumber;
        if (previousState == Call.State.ALERTING) {
          XposedHelpers.callMethod(callRecorder,"String_Node_Str",Environment.getExternalStorageDirectory().getPath() + "String_Node_Str");
        }
 else {
          XposedHelpers.callMethod(callRecorder,"String_Node_Str",Environment.getExternalStorageDirectory().getPath() + "String_Node_Str");
        }
        XposedHelpers.callMethod(callRecorder,"String_Node_Str");
      }
      previousState=state;
    }
  }
);
}
Program: 144222
Project: 144222
Buggy source:
@Override protected void afterHookedMethod(MethodHookParam param) throws Throwable {
  String result=((String)param.getResult()).replaceAll("String_Node_Str","String_Node_Str");
  if (phoneNumber != null && !"String_Node_Str".equals(phoneNumber)) {
    result=phoneNumber + "String_Node_Str" + result;
  }
  if (phoneName != null && !"String_Node_Str".equals(phoneName)) {
    result=phoneName + "String_Node_Str" + result;
  }
  param.setResult(result);
}

Fixed version (ground truth):
@Override protected void afterHookedMethod(MethodHookParam param) throws Throwable {
  String result=((String)param.getResult()).replaceAll("String_Node_Str","String_Node_Str");
  if (phoneNumber != null && !"String_Node_Str".equals(phoneNumber)) {
    result=phoneNumber.replaceAll("String_Node_Str","String_Node_Str") + "String_Node_Str" + result;
  }
  if (phoneName != null && !"String_Node_Str".equals(phoneName)) {
    result=phoneName + "String_Node_Str" + result;
  }
  param.setResult(result);
}
Program: 144224
Project: 144224
Buggy source:
@Override public ClinicalDocument produceCDA(Patient patient,BaseCdaTypeHandler cdaProfileType){
  ClinicalDocument cdaDocument=CDAFactory.eINSTANCE.createClinicalDocument();
  if (cdaProfileType.getTemplateid().equals("String_Node_Str")) {
    APHPHandler aphphandler=new APHPHandler();
    cdaDocument=aphphandler.buildAPHPMessage(patient,cdaProfileType);
  }
 else   if (cdaProfileType.getTemplateid().equals("String_Node_Str")) {
    APSHandler apshandler=new APSHandler();
    cdaDocument=apshandler.buildAPSMessage(patient,cdaProfileType);
  }
  return cdaDocument;
}

Fixed version (ground truth):
@Override public ClinicalDocument produceCDA(Patient patient,BaseCdaTypeHandler cdaProfileType){
  if (patient != null && cdaProfileType != null) {
    ClinicalDocument cdaDocument=CDAFactory.eINSTANCE.createClinicalDocument();
    if (cdaProfileType.getTemplateid().equals("String_Node_Str")) {
      APHPHandler aphphandler=new APHPHandler();
      cdaDocument=aphphandler.buildAPHPMessage(patient,cdaProfileType);
    }
 else     if (cdaProfileType.getTemplateid().equals("String_Node_Str")) {
      APSHandler apshandler=new APSHandler();
      cdaDocument=apshandler.buildAPSMessage(patient,cdaProfileType);
    }
    return cdaDocument;
  }
 else   return null;
}
Program: 144231
Project: 144231
Buggy source:
public static IVL_TS buildDateTime(Date date){
  IVL_TS effectiveTime=DatatypesFactory.eINSTANCE.createIVL_TS();
  SimpleDateFormat s=getDateFormat();
  String creationDate=s.format(date);
  effectiveTime.setValue(creationDate);
  return effectiveTime;
}

Fixed version (ground truth):
public static IVL_TS buildDateTime(Date date){
  IVL_TS effectiveTime=DatatypesFactory.eINSTANCE.createIVL_TS();
  SimpleDateFormat s=new SimpleDateFormat("String_Node_Str");
  String creationDate=s.format(date);
  effectiveTime.setValue(creationDate);
  return effectiveTime;
}
Program: 144232
Project: 144232
Buggy source:
public APHPHandler(){
  this.documentFullName="String_Node_Str";
  this.documentShortName="String_Node_Str";
  this.documentDescription="String_Node_Str";
  this.templateid="String_Node_Str";
  this.formatCode="String_Node_Str";
}

Fixed version (ground truth):
public APHPHandler(){
  this.documentFullName="String_Node_Str";
  this.documentShortName="String_Node_Str";
  this.documentDescription="String_Node_Str";
  this.templateid="String_Node_Str";
  this.parentTemplateId="String_Node_Str";
  this.formatCode="String_Node_Str";
}