Program: 134791
Project: 134791
Buggy source:
/** 
 * This method checks if the guarded activity is due for execution, or if it should be skipped instead. <p> For the first call, it always returns true. Later it returns <code>true</code> if the last call to <code>check()</code>was longer ago than the <code>interval</code>  given in the constructor or in the <code>reset</code> methods,  and/or if the internal counter has been incremented more than <code>maxRepetitions</code>  by calls to   {@link #increment()} or {@link #checkAndIncrement()}.
 * @return <code>true</code> if guarded activity should be run, <code>false</code> if it should be skipped.
 */
public synchronized boolean check(){
  long now=System.nanoTime();
  if (firstTime) {
    firstTime=false;
    counterAtLastExecution=counter;
    counter=0;
    endTimeNs=now + intervalNs;
    return true;
  }
switch (evaluationMethod) {
case AND:
    if ((now >= endTimeNs) && (counter >= maxRepetitions)) {
      counterAtLastExecution=counter;
      counter=0;
      endTimeNs=now + intervalNs;
      return true;
    }
  return false;
case OR:
if ((now >= endTimeNs) || (counter >= maxRepetitions)) {
  counterAtLastExecution=counter;
  counter=0;
  endTimeNs=now + intervalNs;
  return true;
}
return false;
case TIMER:
if (now >= endTimeNs) {
counterAtLastExecution=counter;
counter=0;
while (endTimeNs <= now) {
endTimeNs+=intervalNs;
}
return true;
}
return false;
case COUNTER:
if (counter >= maxRepetitions) {
counterAtLastExecution=counter;
counter=0;
endTimeNs=now + intervalNs;
return true;
}
return false;
}
return false;
}

Fixed version (ground truth):
/** 
 * This method checks if the guarded activity is due for execution, or if it should be skipped instead. <p> For the first call, it always returns true. Later it returns <code>true</code> if the last call to <code>check()</code>was longer ago than the <code>interval</code>  given in the constructor or in the <code>reset</code> methods,  and/or if the internal counter has been incremented more than <code>maxRepetitions</code>  by calls to   {@link #increment()} or {@link #checkAndIncrement()}.
 * @return <code>true</code> if guarded activity should be run, <code>false</code> if it should be skipped.
 */
public synchronized boolean check(){
  long now=System.nanoTime();
  if (firstTime) {
    firstTime=false;
    counterAtLastExecution=counter;
    counter=0;
    endTimeNs=now + intervalNs;
    return true;
  }
switch (evaluationMethod) {
case AND:
    if ((now >= endTimeNs) && (counter >= maxRepetitions)) {
      counterAtLastExecution=counter;
      counter=0;
      endTimeNs=now + intervalNs;
      return true;
    }
  return false;
case OR:
if ((now >= endTimeNs) || (counter >= maxRepetitions)) {
  counterAtLastExecution=counter;
  counter=0;
  endTimeNs=now + intervalNs;
  return true;
}
return false;
case TIMER:
if (now >= endTimeNs) {
counterAtLastExecution=counter;
counter=0;
while (endTimeNs <= now) {
endTimeNs+=intervalNs;
}
return true;
}
return false;
case COUNTER:
if (counter >= maxRepetitions) {
counterAtLastExecution=counter;
counter=0;
endTimeNs=now + intervalNs;
return true;
}
return false;
default :
throw new IllegalStateException("String_Node_Str" + evaluationMethod.toString() + "String_Node_Str");
}
}