nus-yam/ex-repair huggingface dataset:
Program: 13922
Project: 13922
Buggy source:
/** 
 * Returns a copy of this date with the century of era field updated. <p> LocalDate is immutable, so there are no set methods. Instead, this method returns a new instance with the value of century of era changed.
 * @param centuryOfEra  the centurey of era to set
 * @return a copy of this object with the field set
 * @throws IllegalArgumentException if the value is invalid
 */
public LocalDate withCenturyOfEra(int centuryOfEra){
  return withLocalMillis(getChronology().centuryOfEra().set(getLocalMillis(),centuryOfEra));
}

Fixed version (ground truth):
/** 
 * Returns a copy of this date with the century of era field updated. <p> LocalDate is immutable, so there are no set methods. Instead, this method returns a new instance with the value of century of era changed.
 * @param centuryOfEra  the century of era to set
 * @return a copy of this object with the field set
 * @throws IllegalArgumentException if the value is invalid
 */
public LocalDate withCenturyOfEra(int centuryOfEra){
  return withLocalMillis(getChronology().centuryOfEra().set(getLocalMillis(),centuryOfEra));
}
Program: 13923
Project: 13923
Buggy source:
/** 
 * Gets the value of the field at the specifed index. <p> This method is required to support the <code>ReadablePartial</code> interface. The supported fields are Year, MonthOfYear and DayOfMonth. Note that all fields from day and above may in fact be queried via other methods.
 * @param index  the index, zero to two
 * @return the value
 * @throws IndexOutOfBoundsException if the index is invalid
 */
public int getValue(int index){
switch (index) {
case YEAR:
    return getChronology().year().get(getLocalMillis());
case MONTH_OF_YEAR:
  return getChronology().monthOfYear().get(getLocalMillis());
case DAY_OF_MONTH:
return getChronology().dayOfMonth().get(getLocalMillis());
default :
throw new IndexOutOfBoundsException("String_Node_Str" + index);
}
}

Fixed version (ground truth):
/** 
 * Gets the value of the field at the specified index. <p> This method is required to support the <code>ReadablePartial</code> interface. The supported fields are Year, MonthOfYear and DayOfMonth. Note that all fields from day and above may in fact be queried via other methods.
 * @param index  the index, zero to two
 * @return the value
 * @throws IndexOutOfBoundsException if the index is invalid
 */
public int getValue(int index){
switch (index) {
case YEAR:
    return getChronology().year().get(getLocalMillis());
case MONTH_OF_YEAR:
  return getChronology().monthOfYear().get(getLocalMillis());
case DAY_OF_MONTH:
return getChronology().dayOfMonth().get(getLocalMillis());
default :
throw new IndexOutOfBoundsException("String_Node_Str" + index);
}
}
Program: 13924
Project: 13924
Buggy source:
/** 
 * Returns a copy of this datetime with the century of era field updated. <p> LocalDateTime is immutable, so there are no set methods. Instead, this method returns a new instance with the value of century of era changed.
 * @param centuryOfEra  the centurey of era to set
 * @return a copy of this object with the field set
 * @throws IllegalArgumentException if the value is invalid
 */
public LocalDateTime withCenturyOfEra(int centuryOfEra){
  return withLocalMillis(getChronology().centuryOfEra().set(getLocalMillis(),centuryOfEra));
}

Fixed version (ground truth):
/** 
 * Returns a copy of this datetime with the century of era field updated. <p> LocalDateTime is immutable, so there are no set methods. Instead, this method returns a new instance with the value of century of era changed.
 * @param centuryOfEra  the century of era to set
 * @return a copy of this object with the field set
 * @throws IllegalArgumentException if the value is invalid
 */
public LocalDateTime withCenturyOfEra(int centuryOfEra){
  return withLocalMillis(getChronology().centuryOfEra().set(getLocalMillis(),centuryOfEra));
}
Program: 13925
Project: 13925
Buggy source:
/** 
 * Gets the value of the field at the specifed index. <p> This method is required to support the <code>ReadablePartial</code> interface. The supported fields are Year, MonthOfDay, DayOfMonth and MillisOfDay.
 * @param index  the index, zero to two
 * @return the value
 * @throws IndexOutOfBoundsException if the index is invalid
 */
public int getValue(int index){
switch (index) {
case YEAR:
    return getChronology().year().get(getLocalMillis());
case MONTH_OF_YEAR:
  return getChronology().monthOfYear().get(getLocalMillis());
case DAY_OF_MONTH:
return getChronology().dayOfMonth().get(getLocalMillis());
case MILLIS_OF_DAY:
return getChronology().millisOfDay().get(getLocalMillis());
default :
throw new IndexOutOfBoundsException("String_Node_Str" + index);
}
}

Fixed version (ground truth):
/** 
 * Gets the value of the field at the specified index. <p> This method is required to support the <code>ReadablePartial</code> interface. The supported fields are Year, MonthOfDay, DayOfMonth and MillisOfDay.
 * @param index  the index, zero to two
 * @return the value
 * @throws IndexOutOfBoundsException if the index is invalid
 */
public int getValue(int index){
switch (index) {
case YEAR:
    return getChronology().year().get(getLocalMillis());
case MONTH_OF_YEAR:
  return getChronology().monthOfYear().get(getLocalMillis());
case DAY_OF_MONTH:
return getChronology().dayOfMonth().get(getLocalMillis());
case MILLIS_OF_DAY:
return getChronology().millisOfDay().get(getLocalMillis());
default :
throw new IndexOutOfBoundsException("String_Node_Str" + index);
}
}
Program: 13926
Project: 13926
Buggy source:
/** 
 * Gets the value of the field at the specifed index. <p> This method is required to support the <code>ReadablePartial</code> interface. The supported fields are HourOfDay, MinuteOfHour, SecondOfMinute and MillisOfSecond.
 * @param index  the index, zero to three
 * @return the value
 * @throws IndexOutOfBoundsException if the index is invalid
 */
public int getValue(int index){
switch (index) {
case HOUR_OF_DAY:
    return getChronology().hourOfDay().get(getLocalMillis());
case MINUTE_OF_HOUR:
  return getChronology().minuteOfHour().get(getLocalMillis());
case SECOND_OF_MINUTE:
return getChronology().secondOfMinute().get(getLocalMillis());
case MILLIS_OF_SECOND:
return getChronology().millisOfSecond().get(getLocalMillis());
default :
throw new IndexOutOfBoundsException("String_Node_Str" + index);
}
}

Fixed version (ground truth):
/** 
 * Gets the value of the field at the specified index. <p> This method is required to support the <code>ReadablePartial</code> interface. The supported fields are HourOfDay, MinuteOfHour, SecondOfMinute and MillisOfSecond.
 * @param index  the index, zero to three
 * @return the value
 * @throws IndexOutOfBoundsException if the index is invalid
 */
public int getValue(int index){
switch (index) {
case HOUR_OF_DAY:
    return getChronology().hourOfDay().get(getLocalMillis());
case MINUTE_OF_HOUR:
  return getChronology().minuteOfHour().get(getLocalMillis());
case SECOND_OF_MINUTE:
return getChronology().secondOfMinute().get(getLocalMillis());
case MILLIS_OF_SECOND:
return getChronology().millisOfSecond().get(getLocalMillis());
default :
throw new IndexOutOfBoundsException("String_Node_Str" + index);
}
}
Program: 13927
Project: 13927
Buggy source:
/** 
 * Converts this LocalTime to a full datetime using the specified time zone setting the time fields from this instance and the date fields from the current time. <p> This method uses the chronology from this instance plus the time zone specified.
 * @param zone  the zone to use, null means default
 * @return this time as a datetime using todays date
 */
public DateTime toDateTimeToday(DateTimeZone zone){
  Chronology chrono=getChronology().withZone(zone);
  long instantMillis=DateTimeUtils.currentTimeMillis();
  long resolved=chrono.set(this,instantMillis);
  return new DateTime(resolved,chrono);
}

Fixed version (ground truth):
/** 
 * Converts this LocalTime to a full datetime using the specified time zone setting the time fields from this instance and the date fields from the current time. <p> This method uses the chronology from this instance plus the time zone specified.
 * @param zone  the zone to use, null means default
 * @return this time as a datetime using today's date
 */
public DateTime toDateTimeToday(DateTimeZone zone){
  Chronology chrono=getChronology().withZone(zone);
  long instantMillis=DateTimeUtils.currentTimeMillis();
  long resolved=chrono.set(this,instantMillis);
  return new DateTime(resolved,chrono);
}
Program: 13928
Project: 13928
Buggy source:
/** 
 * Creates a <code>Months</code> representing the number of whole months in the specified interval. This method corectly handles any daylight savings time changes that may occur during the interval.
 * @param interval  the interval to extract months from, null returns zero
 * @return the period in months
 * @throws IllegalArgumentException if the partials are null or invalid
 */
public static Months monthsIn(ReadableInterval interval){
  if (interval == null) {
    return Months.ZERO;
  }
  int amount=BaseSingleFieldPeriod.between(interval.getStart(),interval.getEnd(),DurationFieldType.months());
  return Months.months(amount);
}

Fixed version (ground truth):
/** 
 * Creates a <code>Months</code> representing the number of whole months in the specified interval. This method correctly handles any daylight savings time changes that may occur during the interval.
 * @param interval  the interval to extract months from, null returns zero
 * @return the period in months
 * @throws IllegalArgumentException if the partials are null or invalid
 */
public static Months monthsIn(ReadableInterval interval){
  if (interval == null) {
    return Months.ZERO;
  }
  int amount=BaseSingleFieldPeriod.between(interval.getStart(),interval.getEnd(),DurationFieldType.months());
  return Months.months(amount);
}
Program: 13929
Project: 13929
Buggy source:
/** 
 * Gets a copy of this Partial with the value of the specified field increased. If this partial does not support the field, an exception is thrown. <p> If the addition is zero, then <code>this</code> is returned. The addition will overflow into larger fields (eg. minute to hour). If the maximum is reached, the addition will wra.
 * @param fieldType  the field type to add to, not null
 * @param amount  the amount to add
 * @return a copy of this instance with the field updated
 * @throws IllegalArgumentException if the value is null or invalid
 * @throws ArithmeticException if the new datetime exceeds the capacity
 */
public Partial withFieldAddWrapped(DurationFieldType fieldType,int amount){
  int index=indexOfSupported(fieldType);
  if (amount == 0) {
    return this;
  }
  int[] newValues=getValues();
  newValues=getField(index).addWrapPartial(this,index,newValues,amount);
  return new Partial(this,newValues);
}

Fixed version (ground truth):
/** 
 * Gets a copy of this Partial with the value of the specified field increased. If this partial does not support the field, an exception is thrown. <p> If the addition is zero, then <code>this</code> is returned. The addition will overflow into larger fields (eg. minute to hour). If the maximum is reached, the addition will wrap.
 * @param fieldType  the field type to add to, not null
 * @param amount  the amount to add
 * @return a copy of this instance with the field updated
 * @throws IllegalArgumentException if the value is null or invalid
 * @throws ArithmeticException if the new datetime exceeds the capacity
 */
public Partial withFieldAddWrapped(DurationFieldType fieldType,int amount){
  int index=indexOfSupported(fieldType);
  if (amount == 0) {
    return this;
  }
  int[] newValues=getValues();
  newValues=getField(index).addWrapPartial(this,index,newValues,amount);
  return new Partial(this,newValues);
}
Program: 13930
Project: 13930
Buggy source:
/** 
 * Gets a hash code for the duration that is compatable with the  equals method. The following formula must be used: <pre> long len = getMillis(); return (int) (len ^ (len >>> 32)); </pre>
 * @return a hash code
 */
int hashCode();

Fixed version (ground truth):
/** 
 * Gets a hash code for the duration that is compatible with the equals method. The following formula must be used: <pre> long len = getMillis(); return (int) (len ^ (len >>> 32)); </pre>
 * @return a hash code
 */
int hashCode();
Program: 13931
Project: 13931
Buggy source:
/** 
 * Gets a hash code for the time interval that is compatable with the  equals method. <p> The formula used must be as follows: <pre>int result = 97; result = 31 * result + ((int) (getStartMillis() ^ (getStartMillis() >>> 32))); result = 31 * result + ((int) (getEndMillis() ^ (getEndMillis() >>> 32))); result = 31 * result + getChronology().hashCode(); return result;</pre>
 * @return a hash code
 */
int hashCode();

Fixed version (ground truth):
/** 
 * Gets a hash code for the time interval that is compatible with the equals method. <p> The formula used must be as follows: <pre>int result = 97; result = 31 * result + ((int) (getStartMillis() ^ (getStartMillis() >>> 32))); result = 31 * result + ((int) (getEndMillis() ^ (getEndMillis() >>> 32))); result = 31 * result + getChronology().hashCode(); return result;</pre>
 * @return a hash code
 */
int hashCode();
Program: 13932
Project: 13932
Buggy source:
/** 
 * Adds to the value of this field in a copy of this TimeOfDay, throwing an Exception if the bounds are exceeded. <p> The value will be added to this field. If the value is too large to be added solely to this field then it will affect larger fields. Smaller fields are unaffected. <p> If the result would be too large (beyond 23:59:59:999) or too small (less than 00:00:00.000) then an Execption is thrown. For the alternate behaviour which wraps to the next 'day', see   {@link #addToCopy(int)}. <p> The TimeOfDay attached to this property is unchanged by this call. Instead, a new instance is returned.
 * @param valueToAdd  the value to add to the field in the copy
 * @return a copy of the TimeOfDay with the field value changed
 * @throws IllegalArgumentException if the value isn't valid
 */
public TimeOfDay addNoWrapToCopy(int valueToAdd){
  int[] newValues=iTimeOfDay.getValues();
  newValues=getField().add(iTimeOfDay,iFieldIndex,newValues,valueToAdd);
  return new TimeOfDay(iTimeOfDay,newValues);
}

Fixed version (ground truth):
/** 
 * Adds to the value of this field in a copy of this TimeOfDay, throwing an Exception if the bounds are exceeded. <p> The value will be added to this field. If the value is too large to be added solely to this field then it will affect larger fields. Smaller fields are unaffected. <p> If the result would be too large (beyond 23:59:59:999) or too small (less than 00:00:00.000) then an Exception is thrown. For the alternate behaviour which wraps to the next 'day', see   {@link #addToCopy(int)}. <p> The TimeOfDay attached to this property is unchanged by this call. Instead, a new instance is returned.
 * @param valueToAdd  the value to add to the field in the copy
 * @return a copy of the TimeOfDay with the field value changed
 * @throws IllegalArgumentException if the value isn't valid
 */
public TimeOfDay addNoWrapToCopy(int valueToAdd){
  int[] newValues=iTimeOfDay.getValues();
  newValues=getField().add(iTimeOfDay,iFieldIndex,newValues,valueToAdd);
  return new TimeOfDay(iTimeOfDay,newValues);
}
Program: 13933
Project: 13933
Buggy source:
/** 
 * Constructs a YearMonthDay from a <code>java.util.Date</code> using exactly the same field values avoiding any time zone effects. <p> Each field is queried from the Date and assigned to the YearMonthDay. This is useful if you have been using the Date as a local date, ignoing the zone. <p> This factory method always creates a YearMonthDay with ISO chronology.
 * @param date  the Date to extract fields from
 * @return the created YearMonthDay
 * @throws IllegalArgumentException if the calendar is null
 * @throws IllegalArgumentException if the date is invalid for the ISO chronology
 * @since 1.2
 */
public static YearMonthDay fromDateFields(Date date){
  if (date == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  return new YearMonthDay(date.getYear() + 1900,date.getMonth() + 1,date.getDate());
}

Fixed version (ground truth):
/** 
 * Constructs a YearMonthDay from a <code>java.util.Date</code> using exactly the same field values avoiding any time zone effects. <p> Each field is queried from the Date and assigned to the YearMonthDay. This is useful if you have been using the Date as a local date, ignoring the zone. <p> This factory method always creates a YearMonthDay with ISO chronology.
 * @param date  the Date to extract fields from
 * @return the created YearMonthDay
 * @throws IllegalArgumentException if the calendar is null
 * @throws IllegalArgumentException if the date is invalid for the ISO chronology
 * @since 1.2
 */
public static YearMonthDay fromDateFields(Date date){
  if (date == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  return new YearMonthDay(date.getYear() + 1900,date.getMonth() + 1,date.getDate());
}
Program: 13934
Project: 13934
Buggy source:
/** 
 * Constructs a YearMonthDay from a <code>java.util.Calendar</code> using exactly the same field values avoiding any time zone effects. <p> Each field is queried from the Calendar and assigned to the YearMonthDay. This is useful if you have been using the Calendar as a local date, ignoing the zone. <p> This factory method ignores the type of the calendar and always creates a YearMonthDay with ISO chronology. It is expected that you will only pass in instances of <code>GregorianCalendar</code> however this is not validated.
 * @param calendar  the Calendar to extract fields from
 * @return the created YearMonthDay
 * @throws IllegalArgumentException if the calendar is null
 * @throws IllegalArgumentException if the date is invalid for the ISO chronology
 * @since 1.2
 */
public static YearMonthDay fromCalendarFields(Calendar calendar){
  if (calendar == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  return new YearMonthDay(calendar.get(Calendar.YEAR),calendar.get(Calendar.MONTH) + 1,calendar.get(Calendar.DAY_OF_MONTH));
}

Fixed version (ground truth):
/** 
 * Constructs a YearMonthDay from a <code>java.util.Calendar</code> using exactly the same field values avoiding any time zone effects. <p> Each field is queried from the Calendar and assigned to the YearMonthDay. This is useful if you have been using the Calendar as a local date, ignoring the zone. <p> This factory method ignores the type of the calendar and always creates a YearMonthDay with ISO chronology. It is expected that you will only pass in instances of <code>GregorianCalendar</code> however this is not validated.
 * @param calendar  the Calendar to extract fields from
 * @return the created YearMonthDay
 * @throws IllegalArgumentException if the calendar is null
 * @throws IllegalArgumentException if the date is invalid for the ISO chronology
 * @since 1.2
 */
public static YearMonthDay fromCalendarFields(Calendar calendar){
  if (calendar == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  return new YearMonthDay(calendar.get(Calendar.YEAR),calendar.get(Calendar.MONTH) + 1,calendar.get(Calendar.DAY_OF_MONTH));
}
Program: 13935
Project: 13935
Buggy source:
/** 
 * Creates a <code>Years</code> representing the number of whole years in the specified interval. This method corectly handles any daylight savings time changes that may occur during the interval.
 * @param interval  the interval to extract years from, null returns zero
 * @return the period in years
 * @throws IllegalArgumentException if the partials are null or invalid
 */
public static Years yearsIn(ReadableInterval interval){
  if (interval == null) {
    return Years.ZERO;
  }
  int amount=BaseSingleFieldPeriod.between(interval.getStart(),interval.getEnd(),DurationFieldType.years());
  return Years.years(amount);
}

Fixed version (ground truth):
/** 
 * Creates a <code>Years</code> representing the number of whole years in the specified interval. This method correctly handles any daylight savings time changes that may occur during the interval.
 * @param interval  the interval to extract years from, null returns zero
 * @return the period in years
 * @throws IllegalArgumentException if the partials are null or invalid
 */
public static Years yearsIn(ReadableInterval interval){
  if (interval == null) {
    return Years.ZERO;
  }
  int amount=BaseSingleFieldPeriod.between(interval.getStart(),interval.getEnd(),DurationFieldType.years());
  return Years.years(amount);
}
Program: 13936
Project: 13936
Buggy source:
/** 
 * Get the date time as a <code>java.util.GregorianCalendar</code>, assigning exactly the same millisecond instant. <p> The JDK and Joda-Time both have time zone implementations and these differ in accuracy. Joda-Time's implementation is generally more up to date and thus more accurate - for example JDK1.3 has no historical data. The effect of this is that the field values of the <code>Calendar</code> may differ from those of this object, even though the milliseond value is the same. Most of the time this just means that the JDK field values are wrong, as our time zone information is more up to date.
 * @return a GregorianCalendar initialised with this datetime
 */
public GregorianCalendar toGregorianCalendar(){
  DateTimeZone zone=getZone();
  GregorianCalendar cal=new GregorianCalendar(zone.toTimeZone());
  cal.setTime(toDate());
  return cal;
}

Fixed version (ground truth):
/** 
 * Get the date time as a <code>java.util.GregorianCalendar</code>, assigning exactly the same millisecond instant. <p> The JDK and Joda-Time both have time zone implementations and these differ in accuracy. Joda-Time's implementation is generally more up to date and thus more accurate - for example JDK1.3 has no historical data. The effect of this is that the field values of the <code>Calendar</code> may differ from those of this object, even though the millisecond value is the same. Most of the time this just means that the JDK field values are wrong, as our time zone information is more up to date.
 * @return a GregorianCalendar initialised with this datetime
 */
public GregorianCalendar toGregorianCalendar(){
  DateTimeZone zone=getZone();
  GregorianCalendar cal=new GregorianCalendar(zone.toTimeZone());
  cal.setTime(toDate());
  return cal;
}
Program: 13937
Project: 13937
Buggy source:
/** 
 * Get the date time as a <code>java.util.Calendar</code>, assigning exactly the same millisecond instant. The locale is passed in, enabling Calendar to select the correct localized subclass. <p> The JDK and Joda-Time both have time zone implementations and these differ in accuracy. Joda-Time's implementation is generally more up to date and thus more accurate - for example JDK1.3 has no historical data. The effect of this is that the field values of the <code>Calendar</code> may differ from those of this object, even though the milliseond value is the same. Most of the time this just means that the JDK field values are wrong, as our time zone information is more up to date.
 * @param locale  the locale to get the Calendar for, or default if null
 * @return a localized Calendar initialised with this datetime
 */
public Calendar toCalendar(Locale locale){
  if (locale == null) {
    locale=Locale.getDefault();
  }
  DateTimeZone zone=getZone();
  Calendar cal=Calendar.getInstance(zone.toTimeZone(),locale);
  cal.setTime(toDate());
  return cal;
}

Fixed version (ground truth):
/** 
 * Get the date time as a <code>java.util.Calendar</code>, assigning exactly the same millisecond instant. The locale is passed in, enabling Calendar to select the correct localized subclass. <p> The JDK and Joda-Time both have time zone implementations and these differ in accuracy. Joda-Time's implementation is generally more up to date and thus more accurate - for example JDK1.3 has no historical data. The effect of this is that the field values of the <code>Calendar</code> may differ from those of this object, even though the millisecond value is the same. Most of the time this just means that the JDK field values are wrong, as our time zone information is more up to date.
 * @param locale  the locale to get the Calendar for, or default if null
 * @return a localized Calendar initialised with this datetime
 */
public Calendar toCalendar(Locale locale){
  if (locale == null) {
    locale=Locale.getDefault();
  }
  DateTimeZone zone=getZone();
  Calendar cal=Calendar.getInstance(zone.toTimeZone(),locale);
  cal.setTime(toDate());
  return cal;
}
Program: 13938
Project: 13938
Buggy source:
/** 
 * Gets the field at the specifed index.
 * @param index  the index
 * @return the field
 * @throws IndexOutOfBoundsException if the index is invalid
 */
public DateTimeField getField(int index){
  return getField(index,getChronology());
}

Fixed version (ground truth):
/** 
 * Gets the field at the specified index.
 * @param index  the index
 * @return the field
 * @throws IndexOutOfBoundsException if the index is invalid
 */
public DateTimeField getField(int index){
  return getField(index,getChronology());
}
Program: 13939
Project: 13939
Buggy source:
/** 
 * Gets the field type at the specifed index.
 * @param index  the index
 * @return the field type
 * @throws IndexOutOfBoundsException if the index is invalid
 */
public DateTimeFieldType getFieldType(int index){
  return getField(index,getChronology()).getType();
}

Fixed version (ground truth):
/** 
 * Gets the field type at the specified index.
 * @param index  the index
 * @return the field type
 * @throws IndexOutOfBoundsException if the index is invalid
 */
public DateTimeFieldType getFieldType(int index){
  return getField(index,getChronology()).getType();
}
Program: 13940
Project: 13940
Buggy source:
static int csCompare(CharSequence text,int position,String search){
  int compareLen=Math.min(text.length() - position,search.length());
  for (int i=0; i < compareLen; i++) {
    int result=search.charAt(i) - text.charAt(position + i);
    if (result != 0) {
      return result;
    }
  }
  return 0;
}

Fixed version (ground truth):
static int csCompare(CharSequence text,int position,String search){
  int matchLen=text.length() - position;
  int searchLen=search.length();
  int compareLen=Math.min(matchLen,searchLen);
  for (int i=0; i < compareLen; i++) {
    int result=search.charAt(i) - text.charAt(position + i);
    if (result != 0) {
      return result;
    }
  }
  return searchLen - matchLen;
}
Program: 13941
Project: 13941
Buggy source:
Rule(StringTokenizer st){
  iName=st.nextToken().intern();
  iFromYear=parseYear(st.nextToken(),0);
  iToYear=parseYear(st.nextToken(),iFromYear);
  if (iToYear < iFromYear) {
    throw new IllegalArgumentException();
  }
  iType=parseOptional(st.nextToken());
  iDateTimeOfYear=new DateTimeOfYear(st);
  iSaveMillis=parseTime(st.nextToken());
  iLetterS=parseOptional(st.nextToken());
}

Fixed version (ground truth):
Rule(StringTokenizer st){
  if (st.countTokens() < 6) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  iName=st.nextToken().intern();
  iFromYear=parseYear(st.nextToken(),0);
  iToYear=parseYear(st.nextToken(),iFromYear);
  if (iToYear < iFromYear) {
    throw new IllegalArgumentException();
  }
  iType=parseOptional(st.nextToken());
  iDateTimeOfYear=new DateTimeOfYear(st);
  iSaveMillis=parseTime(st.nextToken());
  iLetterS=parseOptional(st.nextToken());
}
Program: 13943
Project: 13943
Buggy source:
/** 
 * Creates a new interval with the specified start millisecond instant.
 * @param endInstant  the end instant for the new interval
 * @return an interval with the start from this interval and the specified end
 * @throws IllegalArgumentException if the resulting interval has end before start
 */
public Interval withEndMillis(long endInstant){
  if (endInstant == getEndMillis()) {
    return this;
  }
  return new Interval(getStartMillis(),endInstant,getChronology());
}

Fixed version (ground truth):
/** 
 * Creates a new interval with the specified end millisecond instant.
 * @param endInstant  the end instant for the new interval
 * @return an interval with the start from this interval and the specified end
 * @throws IllegalArgumentException if the resulting interval has end before start
 */
public Interval withEndMillis(long endInstant){
  if (endInstant == getEndMillis()) {
    return this;
  }
  return new Interval(getStartMillis(),endInstant,getChronology());
}
Program: 13944
Project: 13944
Buggy source:
/** 
 * Gets the duration of this time interval in milliseconds. <p> The duration is equal to the end millis minus the start millis.
 * @return the duration of the time interval in milliseconds
 * @throws ArithmeticException if the duration exceeds the capacity of a long
 */
public long toDurationMillis(){
  return FieldUtils.safeAdd(getEndMillis(),-getStartMillis());
}

Fixed version (ground truth):
/** 
 * Gets the duration of this time interval in milliseconds. <p> The duration is equal to the end millis minus the start millis.
 * @return the duration of the time interval in milliseconds
 * @throws ArithmeticException if the duration exceeds the capacity of a long
 */
public long toDurationMillis(){
  return FieldUtils.safeSubtract(getEndMillis(),getStartMillis());
}
Program: 13945
Project: 13945
Buggy source:
public void testPatchedNameKeysGazaHistoric() throws Exception {
  DateTimeZone zone=DateTimeZone.forID("String_Node_Str");
  DateTime now=new DateTime(1944,1,1,0,0,0,0);
  String str1=zone.getName(now.getMillis());
  String str2=zone.getName(now.plusMonths(6).getMillis());
  assertEquals(false,str1.equals(str2));
}

Fixed version (ground truth):
public void testPatchedNameKeysGazaHistoric() throws Exception {
  DateTimeZone zone=DateTimeZone.forID("String_Node_Str");
  DateTime now=new DateTime(1943,1,1,0,0,0,0);
  String str1=zone.getName(now.getMillis());
  String str2=zone.getName(now.plusMonths(6).getMillis());
  assertEquals(false,str1.equals(str2));
}
Program: 13946
Project: 13946
Buggy source:
protected int getMaximumValueForSet(long instant,int value){
  int maxLessOne=iChronology.getDaysInYearMax() - 1;
  return value > maxLessOne ? getMaximumValue(instant) : maxLessOne;
}

Fixed version (ground truth):
protected int getMaximumValueForSet(long instant,int value){
  int maxLessOne=iChronology.getDaysInYearMax() - 1;
  return (value > maxLessOne || value < 1) ? getMaximumValue(instant) : maxLessOne;
}
Program: 13947
Project: 13947
Buggy source:
/** 
 * Gets an instance of the CopticChronology. The time zone of the returned instance is UTC.
 * @return a singleton UTC instance of the chronology
 */
public static IslamicChronology getInstanceUTC(){
  return INSTANCE_UTC;
}

Fixed version (ground truth):
/** 
 * Gets an instance of the IslamicChronology. The time zone of the returned instance is UTC.
 * @return a singleton UTC instance of the chronology
 */
public static IslamicChronology getInstanceUTC(){
  return INSTANCE_UTC;
}
Program: 13948
Project: 13948
Buggy source:
/** 
 * Gets an instance of the CopticChronology in the given time zone.
 * @param zone  the time zone to get the chronology in, null is default
 * @param leapYears  the type defining the leap year pattern
 * @return a chronology in the specified time zone
 */
public static IslamicChronology getInstance(DateTimeZone zone,LeapYearPatternType leapYears){
  if (zone == null) {
    zone=DateTimeZone.getDefault();
  }
  IslamicChronology chrono;
synchronized (cCache) {
    IslamicChronology[] chronos=(IslamicChronology[])cCache.get(zone);
    if (chronos == null) {
      chronos=new IslamicChronology[4];
      cCache.put(zone,chronos);
    }
    chrono=chronos[leapYears.index];
    if (chrono == null) {
      if (zone == DateTimeZone.UTC) {
        chrono=new IslamicChronology(null,null,leapYears);
        DateTime lowerLimit=new DateTime(1,1,1,0,0,0,0,chrono);
        chrono=new IslamicChronology(LimitChronology.getInstance(chrono,lowerLimit,null),null,leapYears);
      }
 else {
        chrono=getInstance(DateTimeZone.UTC,leapYears);
        chrono=new IslamicChronology(ZonedChronology.getInstance(chrono,zone),null,leapYears);
      }
      chronos[leapYears.index]=chrono;
    }
  }
  return chrono;
}

Fixed version (ground truth):
/** 
 * Gets an instance of the IslamicChronology in the given time zone.
 * @param zone  the time zone to get the chronology in, null is default
 * @param leapYears  the type defining the leap year pattern
 * @return a chronology in the specified time zone
 */
public static IslamicChronology getInstance(DateTimeZone zone,LeapYearPatternType leapYears){
  if (zone == null) {
    zone=DateTimeZone.getDefault();
  }
  IslamicChronology chrono;
synchronized (cCache) {
    IslamicChronology[] chronos=(IslamicChronology[])cCache.get(zone);
    if (chronos == null) {
      chronos=new IslamicChronology[4];
      cCache.put(zone,chronos);
    }
    chrono=chronos[leapYears.index];
    if (chrono == null) {
      if (zone == DateTimeZone.UTC) {
        chrono=new IslamicChronology(null,null,leapYears);
        DateTime lowerLimit=new DateTime(1,1,1,0,0,0,0,chrono);
        chrono=new IslamicChronology(LimitChronology.getInstance(chrono,lowerLimit,null),null,leapYears);
      }
 else {
        chrono=getInstance(DateTimeZone.UTC,leapYears);
        chrono=new IslamicChronology(ZonedChronology.getInstance(chrono,zone),null,leapYears);
      }
      chronos[leapYears.index]=chrono;
    }
  }
  return chrono;
}
Program: 13949
Project: 13949
Buggy source:
public void testForStyle_shortTime() throws Exception {
  DateTimeFormatter f=DateTimeFormat.shortTime();
  DateTimeFormatter g=DateTimeFormat.forStyle("String_Node_Str");
  assertSame(g,f);
  DateTime dt=new DateTime(2004,6,9,10,20,30,0);
  String expect=DateFormat.getTimeInstance(DateFormat.SHORT,UK).format(dt.toDate());
  assertEquals(expect,f.print(dt));
  expect=DateFormat.getTimeInstance(DateFormat.SHORT,US).format(dt.toDate());
  assertEquals(expect,f.withLocale(US).print(dt));
  expect=DateFormat.getTimeInstance(DateFormat.SHORT,FRANCE).format(dt.toDate());
  assertEquals(expect,f.withLocale(FRANCE).print(dt));
  DateTime date=new DateTime(DateFormat.getTimeInstance(DateFormat.SHORT,FRANCE).parse(expect));
  assertEquals(date,f.withLocale(FRANCE).parseDateTime(expect));
}

Fixed version (ground truth):
public void testForStyle_shortTime() throws Exception {
  DateTimeFormatter f=DateTimeFormat.shortTime();
  DateTimeFormatter g=DateTimeFormat.forStyle("String_Node_Str");
  assertSame(g,f);
  DateTime dt=new DateTime(2004,6,9,10,20,30,0);
  String expect=DateFormat.getTimeInstance(DateFormat.SHORT,UK).format(dt.toDate());
  assertEquals(expect,f.print(dt));
  expect=DateFormat.getTimeInstance(DateFormat.SHORT,US).format(dt.toDate());
  assertEquals(expect,f.withLocale(US).print(dt));
  expect=DateFormat.getTimeInstance(DateFormat.SHORT,FRANCE).format(dt.toDate());
  assertEquals(expect,f.withLocale(FRANCE).print(dt));
  if (TimeZone.getDefault() instanceof SimpleTimeZone) {
  }
 else {
    DateTime date=new DateTime(DateFormat.getTimeInstance(DateFormat.SHORT,FRANCE).parse(expect));
    assertEquals(date,f.withLocale(FRANCE).parseDateTime(expect));
  }
}
Program: 13950
Project: 13950
Buggy source:
protected void assemble(Fields fields){
  if (getParam() == null) {
    DateTimeField field=fields.year;
    fields.year=new OffsetDateTimeField(field,BUDDHIST_OFFSET);
    field=fields.yearOfEra;
    fields.yearOfEra=new OffsetDateTimeField(fields.year,DateTimeFieldType.yearOfEra(),BUDDHIST_OFFSET);
    field=fields.weekyear;
    fields.weekyear=new OffsetDateTimeField(field,BUDDHIST_OFFSET);
    field=new OffsetDateTimeField(fields.yearOfEra,99);
    fields.centuryOfEra=new DividedDateTimeField(field,DateTimeFieldType.centuryOfEra(),100);
    field=new RemainderDateTimeField((DividedDateTimeField)fields.centuryOfEra);
    fields.yearOfCentury=new OffsetDateTimeField(field,DateTimeFieldType.yearOfCentury(),1);
    field=new RemainderDateTimeField(fields.weekyear,DateTimeFieldType.weekyearOfCentury(),100);
    fields.weekyearOfCentury=new OffsetDateTimeField(field,DateTimeFieldType.weekyearOfCentury(),1);
    fields.era=ThaiBuddhistEraDateTimeField.INSTANCE;
  }
}

Fixed version (ground truth):
protected void assemble(Fields fields){
  if (getParam() == null) {
    DateTimeField field=fields.year;
    fields.year=new OffsetDateTimeField(new SkipUndoDateTimeField(this,field),BUDDHIST_OFFSET);
    field=fields.yearOfEra;
    fields.yearOfEra=new DelegatedDateTimeField(fields.year,DateTimeFieldType.yearOfEra());
    field=fields.weekyear;
    fields.weekyear=new OffsetDateTimeField(new SkipUndoDateTimeField(this,field),BUDDHIST_OFFSET);
    field=new OffsetDateTimeField(fields.yearOfEra,99);
    fields.centuryOfEra=new DividedDateTimeField(field,DateTimeFieldType.centuryOfEra(),100);
    field=new RemainderDateTimeField((DividedDateTimeField)fields.centuryOfEra);
    fields.yearOfCentury=new OffsetDateTimeField(field,DateTimeFieldType.yearOfCentury(),1);
    field=new RemainderDateTimeField(fields.weekyear,DateTimeFieldType.weekyearOfCentury(),100);
    fields.weekyearOfCentury=new OffsetDateTimeField(field,DateTimeFieldType.weekyearOfCentury(),1);
    fields.era=ThaiBuddhistEraDateTimeField.INSTANCE;
  }
}
Program: 13951
Project: 13951
Buggy source:
/** 
 * Constructor.
 * @param field  the field being decorated
 * @param type  the field type override
 */
protected DelegatedDateTimeField(DateTimeField field,DateTimeFieldType type){
  super();
  if (field == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  iField=field;
  iType=(type == null ? field.getType() : type);
}

Fixed version (ground truth):
/** 
 * Constructor.
 * @param field  the field being decorated
 * @param type  the field type override
 */
public DelegatedDateTimeField(DateTimeField field,DateTimeFieldType type){
  super();
  if (field == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  iField=field;
  iType=(type == null ? field.getType() : type);
}
Program: 13952
Project: 13952
Buggy source:
/** 
 * Gets a copy of this date with the value of the specified field increased. <p> If the addition is zero, then <code>this</code> is returned. <p> These three lines are equivalent: <pre> YearMonthDay added = ymd.withField(DateTimeFieldType.dayOfMonth(), 6); YearMonthDay added = ymd.dayOfMonth().addToCopy(6); YearMonthDay added = ymd.property(DateTimeFieldType.dayOfMonth()).addToCopy(6); </pre>
 * @param fieldType  the field type to add to, not null
 * @param amount  the amount to add
 * @return a copy of this instance with the field updated
 * @throws IllegalArgumentException if the value is null or invalid
 * @throws ArithmeticException if the new datetime exceeds the capacity
 */
public YearMonthDay withFieldAdded(DurationFieldType fieldType,int amount){
  if (amount == 0) {
    return this;
  }
  int index=indexOfSupported(fieldType);
  int[] newValues=getValues();
  newValues=getField(index).add(this,index,newValues,amount);
  return new YearMonthDay(this,newValues);
}

Fixed version (ground truth):
/** 
 * Gets a copy of this date with the value of the specified field increased. <p> If the addition is zero, then <code>this</code> is returned. <p> These three lines are equivalent: <pre> YearMonthDay added = ymd.withFieldAdded(DateTimeFieldType.dayOfMonth(), 6); YearMonthDay added = ymd.dayOfMonth().addToCopy(6); YearMonthDay added = ymd.property(DateTimeFieldType.dayOfMonth()).addToCopy(6); </pre>
 * @param fieldType  the field type to add to, not null
 * @param amount  the amount to add
 * @return a copy of this instance with the field updated
 * @throws IllegalArgumentException if the value is null or invalid
 * @throws ArithmeticException if the new datetime exceeds the capacity
 */
public YearMonthDay withFieldAdded(DurationFieldType fieldType,int amount){
  int index=indexOfSupported(fieldType);
  if (amount == 0) {
    return this;
  }
  int[] newValues=getValues();
  newValues=getField(index).add(this,index,newValues,amount);
  return new YearMonthDay(this,newValues);
}
Program: 13953
Project: 13953
Buggy source:
/** 
 * Gets a copy of this date with the specified field set to a new value. <p> For example, if the field type is <code>dayOfMonth</code> then the day would be changed in the returned instance. <p> These three lines are equivalent: <pre> YearMonthDay updated = ymd.withField(DateTimeFieldType.dayOfMonth(), 6); YearMonthDay updated = ymd.dayOfMonth().setCopy(6); YearMonthDay updated = ymd.property(DateTimeFieldType.dayOfMonth()).setCopy(6); </pre>
 * @param fieldType  the field type to set, not null
 * @param value  the value to set
 * @return a copy of this instance with the field set
 * @throws IllegalArgumentException if the value is null or invalid
 */
public YearMonthDay withField(DateTimeFieldType fieldType,int value){
  if (value == 0) {
    return this;
  }
  int index=indexOfSupported(fieldType);
  int[] newValues=getValues();
  newValues=getField(index).set(this,index,newValues,value);
  return new YearMonthDay(this,newValues);
}

Fixed version (ground truth):
/** 
 * Gets a copy of this date with the specified field set to a new value. <p> For example, if the field type is <code>dayOfMonth</code> then the day would be changed in the returned instance. <p> These three lines are equivalent: <pre> YearMonthDay updated = ymd.withField(DateTimeFieldType.dayOfMonth(), 6); YearMonthDay updated = ymd.dayOfMonth().setCopy(6); YearMonthDay updated = ymd.property(DateTimeFieldType.dayOfMonth()).setCopy(6); </pre>
 * @param fieldType  the field type to set, not null
 * @param value  the value to set
 * @return a copy of this instance with the field set
 * @throws IllegalArgumentException if the value is null or invalid
 */
public YearMonthDay withField(DateTimeFieldType fieldType,int value){
  int index=indexOfSupported(fieldType);
  if (value == 0) {
    return this;
  }
  int[] newValues=getValues();
  newValues=getField(index).set(this,index,newValues,value);
  return new YearMonthDay(this,newValues);
}
Program: 13954
Project: 13954
Buggy source:
/** 
 * Gets a copy of this date with the specified field set to a new value. <p> For example, if the field type is <code>dayOfMonth</code> then the day would be changed in the returned instance. <p> These three lines are equivalent: <pre> YearMonthDay updated = ymd.withField(DateTimeFieldType.dayOfMonth(), 6); YearMonthDay updated = ymd.dayOfMonth().setCopy(6); YearMonthDay updated = ymd.property(DateTimeFieldType.dayOfMonth()).setCopy(6); </pre>
 * @param fieldType  the field type to set, not null
 * @param value  the value to set
 * @return a copy of this instance with the field set
 * @throws IllegalArgumentException if the value is null or invalid
 */
public YearMonthDay withField(DateTimeFieldType fieldType,int value){
  int index=indexOfSupported(fieldType);
  if (value == 0) {
    return this;
  }
  int[] newValues=getValues();
  newValues=getField(index).set(this,index,newValues,value);
  return new YearMonthDay(this,newValues);
}

Fixed version (ground truth):
/** 
 * Gets a copy of this date with the specified field set to a new value. <p> For example, if the field type is <code>dayOfMonth</code> then the day would be changed in the returned instance. <p> These three lines are equivalent: <pre> YearMonthDay updated = ymd.withField(DateTimeFieldType.dayOfMonth(), 6); YearMonthDay updated = ymd.dayOfMonth().setCopy(6); YearMonthDay updated = ymd.property(DateTimeFieldType.dayOfMonth()).setCopy(6); </pre>
 * @param fieldType  the field type to set, not null
 * @param value  the value to set
 * @return a copy of this instance with the field set
 * @throws IllegalArgumentException if the value is null or invalid
 */
public YearMonthDay withField(DateTimeFieldType fieldType,int value){
  int index=indexOfSupported(fieldType);
  if (value == getValue(index)) {
    return this;
  }
  int[] newValues=getValues();
  newValues=getField(index).set(this,index,newValues,value);
  return new YearMonthDay(this,newValues);
}
Program: 13955
Project: 13955
Buggy source:
/** 
 * Gets the long name of this datetime zone suitable for display using the specified locale. <p> If the name is not available for the locale, then this method returns a string in the format <code>[+-]hh:mm</code>.
 * @param instant  milliseconds from 1970-01-01T00:00:00Z to get the name for
 * @param locale  the locale to get the name for
 * @return the human-readable long name in the specified locale
 */
public String getName(long instant,Locale locale){
  if (locale == null) {
    locale=Locale.getDefault();
  }
  String nameKey=getNameKey(instant);
  if (nameKey == null) {
    return iID;
  }
  String name=cNameProvider.getName(locale,iID,nameKey);
  if (name != null) {
    return name;
  }
  return printTimeZone(getOffset(instant));
}

Fixed version (ground truth):
/** 
 * Gets the long name of this datetime zone suitable for display using the specified locale. <p> If the name is not available for the locale, then this method returns a string in the format <code>[+-]hh:mm</code>.
 * @param instant  milliseconds from 1970-01-01T00:00:00Z to get the name for
 * @param locale  the locale to get the name for
 * @return the human-readable long name in the specified locale
 */
public String getName(long instant,Locale locale){
  if (locale == null) {
    locale=Locale.getDefault();
  }
  String nameKey=getNameKey(instant);
  if (nameKey == null) {
    return iID;
  }
  String name=cNameProvider.getName(locale,iID,nameKey);
  if (name != null) {
    return name;
  }
  return printOffset(getOffset(instant));
}
Program: 13956
Project: 13956
Buggy source:
/** 
 * Gets the short name of this datetime zone suitable for display using the specified locale. <p> If the name is not available for the locale, then this method returns a string in the format <code>[+-]hh:mm</code>.
 * @param instant  milliseconds from 1970-01-01T00:00:00Z to get the name for
 * @param locale  the locale to get the name for
 * @return the human-readable short name in the specified locale
 */
public String getShortName(long instant,Locale locale){
  if (locale == null) {
    locale=Locale.getDefault();
  }
  String nameKey=getNameKey(instant);
  if (nameKey == null) {
    return iID;
  }
  String name=cNameProvider.getShortName(locale,iID,nameKey);
  if (name != null) {
    return name;
  }
  return printTimeZone(getOffset(instant));
}

Fixed version (ground truth):
/** 
 * Gets the short name of this datetime zone suitable for display using the specified locale. <p> If the name is not available for the locale, then this method returns a string in the format <code>[+-]hh:mm</code>.
 * @param instant  milliseconds from 1970-01-01T00:00:00Z to get the name for
 * @param locale  the locale to get the name for
 * @return the human-readable short name in the specified locale
 */
public String getShortName(long instant,Locale locale){
  if (locale == null) {
    locale=Locale.getDefault();
  }
  String nameKey=getNameKey(instant);
  if (nameKey == null) {
    return iID;
  }
  String name=cNameProvider.getShortName(locale,iID,nameKey);
  if (name != null) {
    return name;
  }
  return printOffset(getOffset(instant));
}