nus-yam/ex-repair huggingface dataset:
Program: 11236
Project: 11236
Buggy source:
/** 
 * Returns the non-primitive   {@link Class} closest to the given type.<p> Specifically, the following type conversions are done: <ul> <li>boolean.class becomes Boolean.class</li> <li>byte.class becomes Byte.class</li> <li>char.class becomes Character.class</li> <li>double.class becomes Double.class</li> <li>float.class becomes Float.class</li> <li>int.class becomes Integer.class</li> <li>long.class becomes Long.class</li> <li>short.class becomes Short.class</li> <li>void.class becomes Void.class</li> </ul> All other types are unchanged. </p>
 */
public static <T>Class<T> box(final Class<T> type){
  final Class<?> destType;
  if (type == boolean.class)   destType=Boolean.class;
 else   if (type == byte.class)   destType=Byte.class;
 else   if (type == char.class)   destType=Character.class;
 else   if (type == double.class)   destType=Double.class;
 else   if (type == float.class)   destType=Float.class;
 else   if (type == int.class)   destType=Integer.class;
 else   if (type == long.class)   destType=Long.class;
 else   if (type == short.class)   destType=Short.class;
 else   if (type == void.class)   destType=Void.class;
 else   destType=type;
  @SuppressWarnings("String_Node_Str") final Class<T> result=(Class<T>)destType;
  return result;
}

Fixed version (ground truth):
/** 
 * Returns the non-primitive   {@link Class} closest to the given type.<p> Specifically, the following type conversions are done: </p> <ul> <li>boolean.class becomes Boolean.class</li> <li>byte.class becomes Byte.class</li> <li>char.class becomes Character.class</li> <li>double.class becomes Double.class</li> <li>float.class becomes Float.class</li> <li>int.class becomes Integer.class</li> <li>long.class becomes Long.class</li> <li>short.class becomes Short.class</li> <li>void.class becomes Void.class</li> </ul> <p> All other types are unchanged. </p>
 */
public static <T>Class<T> box(final Class<T> type){
  final Class<?> destType;
  if (type == boolean.class)   destType=Boolean.class;
 else   if (type == byte.class)   destType=Byte.class;
 else   if (type == char.class)   destType=Character.class;
 else   if (type == double.class)   destType=Double.class;
 else   if (type == float.class)   destType=Float.class;
 else   if (type == int.class)   destType=Integer.class;
 else   if (type == long.class)   destType=Long.class;
 else   if (type == short.class)   destType=Short.class;
 else   if (type == void.class)   destType=Void.class;
 else   destType=type;
  @SuppressWarnings("String_Node_Str") final Class<T> result=(Class<T>)destType;
  return result;
}
Program: 11237
Project: 11237
Buggy source:
@Override public UserInterface getDefaultUI(){
  if (isHeadless())   return uiMap().get(HeadlessUI.NAME);
  if (defaultUI != null)   return defaultUI;
  return uiList().isEmpty() ? null : uiList().get(0);
}

Fixed version (ground truth):
@Override public UserInterface getDefaultUI(){
  if (!initialized)   discoverUIs();
  if (isHeadless())   return uiMap().get(HeadlessUI.NAME);
  if (defaultUI != null)   return defaultUI;
  return uiList().isEmpty() ? null : uiList().get(0);
}
Program: 11238
Project: 11238
Buggy source:
@Override public void run(){
  save();
  for (  final ModuleItem<?> input : getInfo().inputs()) {
    unresolveInput(input.getName());
  }
  eventService.publish(new OptionsEvent(this));
}

Fixed version (ground truth):
@Override public void run(){
  save();
  eventService.publish(new OptionsEvent(this));
  resetState();
}
Program: 11239
Project: 11239
Buggy source:
/** 
 * Format a   {@link WildcardType} as a {@link String}.
 * @param w {@code WildcardType} to format
 * @return String
 * @since 3.2
 */
private static String wildcardTypeToString(final WildcardType w){
  final StringBuilder buf=new StringBuilder().append('?');
  final Type[] lowerBounds=w.getLowerBounds();
  final Type[] upperBounds=w.getUpperBounds();
  if (lowerBounds.length > 1 || lowerBounds.length == 1 && lowerBounds[0] != null) {
    appendAllTo(buf.append("String_Node_Str"),"String_Node_Str",lowerBounds);
  }
 else   if (upperBounds.length > 1 || upperBounds.length == 1 && !Object.class.equals(upperBounds[0])) {
    appendAllTo(buf.append("String_Node_Str"),"String_Node_Str",upperBounds);
  }
  return buf.toString();
}

Fixed version (ground truth):
/** 
 * Format a   {@link WildcardType} as a {@link String}.
 * @param w {@code WildcardType} to format
 * @param done list of already-encountered types
 * @return String
 * @since 3.2
 */
private static String wildcardTypeToString(final WildcardType w,final Set<Type> done){
  final StringBuilder buf=new StringBuilder().append('?');
  if (done.contains(w))   return buf.toString();
  done.add(w);
  final Type[] lowerBounds=w.getLowerBounds();
  final Type[] upperBounds=w.getUpperBounds();
  if (lowerBounds.length > 1 || lowerBounds.length == 1 && lowerBounds[0] != null) {
    appendAllTo(buf.append("String_Node_Str"),"String_Node_Str",done,lowerBounds);
  }
 else   if (upperBounds.length > 1 || upperBounds.length == 1 && !Object.class.equals(upperBounds[0])) {
    appendAllTo(buf.append("String_Node_Str"),"String_Node_Str",done,upperBounds);
  }
  return buf.toString();
}
Program: 11240
Project: 11240
Buggy source:
/** 
 * Format a   {@link TypeVariable} including its {@link GenericDeclaration}.
 * @param var the type variable to create a String representation for, not{@code null}
 * @return String
 * @since 3.2
 */
public static String toLongString(final TypeVariable<?> var){
  validateNotNull(var,"String_Node_Str");
  final StringBuilder buf=new StringBuilder();
  final GenericDeclaration d=((TypeVariable<?>)var).getGenericDeclaration();
  if (d instanceof Class<?>) {
    Class<?> c=(Class<?>)d;
    while (true) {
      if (c.getEnclosingClass() == null) {
        buf.insert(0,c.getName());
        break;
      }
      buf.insert(0,c.getSimpleName()).insert(0,'.');
      c=c.getEnclosingClass();
    }
  }
 else   if (d instanceof Type) {
    buf.append(toString((Type)d));
  }
 else {
    buf.append(d);
  }
  return buf.append(':').append(typeVariableToString(var)).toString();
}

Fixed version (ground truth):
/** 
 * Format a   {@link TypeVariable} including its {@link GenericDeclaration}.
 * @param var the type variable to create a String representation for, not{@code null}
 * @return String
 * @since 3.2
 */
public static String toLongString(final TypeVariable<?> var){
  validateNotNull(var,"String_Node_Str");
  final StringBuilder buf=new StringBuilder();
  final GenericDeclaration d=((TypeVariable<?>)var).getGenericDeclaration();
  if (d instanceof Class<?>) {
    Class<?> c=(Class<?>)d;
    while (true) {
      if (c.getEnclosingClass() == null) {
        buf.insert(0,c.getName());
        break;
      }
      buf.insert(0,c.getSimpleName()).insert(0,'.');
      c=c.getEnclosingClass();
    }
  }
 else   if (d instanceof Type) {
    buf.append(toString((Type)d));
  }
 else {
    buf.append(d);
  }
  return buf.append(':').append(typeVariableToString(var,new HashSet<>())).toString();
}
Program: 11241
Project: 11241
Buggy source:
/** 
 * Format a   {@link TypeVariable} as a {@link String}.
 * @param v {@code TypeVariable} to format
 * @return String
 * @since 3.2
 */
private static String typeVariableToString(final TypeVariable<?> v){
  final StringBuilder buf=new StringBuilder(v.getName());
  final Type[] bounds=v.getBounds();
  if (bounds.length > 0 && !(bounds.length == 1 && Object.class.equals(bounds[0]))) {
    buf.append("String_Node_Str");
    appendAllTo(buf,"String_Node_Str",v.getBounds());
  }
  return buf.toString();
}

Fixed version (ground truth):
/** 
 * Format a   {@link TypeVariable} as a {@link String}.
 * @param v {@code TypeVariable} to format
 * @param done list of already-encountered types
 * @return String
 * @since 3.2
 */
private static String typeVariableToString(final TypeVariable<?> v,final Set<Type> done){
  final StringBuilder buf=new StringBuilder(v.getName());
  if (done.contains(v))   return buf.toString();
  done.add(v);
  final Type[] bounds=v.getBounds();
  if (bounds.length > 0 && !(bounds.length == 1 && Object.class.equals(bounds[0]))) {
    buf.append("String_Node_Str");
    appendAllTo(buf,"String_Node_Str",done,v.getBounds());
  }
  return buf.toString();
}
Program: 11242
Project: 11242
Buggy source:
/** 
 * Append   {@code types} to {@code buf} with separator {@code sep}.
 * @param buf destination
 * @param sep separator
 * @param types to append
 * @return {@code buf}
 * @since 3.2
 */
private static StringBuilder appendAllTo(final StringBuilder buf,final String sep,final Type... types){
  validateNotEmpty(validateNoNullElements(types));
  if (types.length > 0) {
    buf.append(toString(types[0]));
    for (int i=1; i < types.length; i++) {
      buf.append(sep).append(toString(types[i]));
    }
  }
  return buf;
}

Fixed version (ground truth):
/** 
 * Append   {@code types} to {@code buf} with separator {@code sep}.
 * @param buf destination
 * @param sep separator
 * @param done list of already-encountered types
 * @param types to append
 * @return {@code buf}
 * @since 3.2
 */
private static StringBuilder appendAllTo(final StringBuilder buf,final String sep,final Set<Type> done,final Type... types){
  validateNotEmpty(validateNoNullElements(types));
  if (types.length > 0) {
    buf.append(toString(types[0],done));
    for (int i=1; i < types.length; i++) {
      buf.append(sep).append(toString(types[i],done));
    }
  }
  return buf;
}
Program: 11243
Project: 11243
Buggy source:
/** 
 * Format a   {@link Class} as a {@link String}.
 * @param c {@code Class} to format
 * @return String
 * @since 3.2
 */
private static String classToString(final Class<?> c){
  final StringBuilder buf=new StringBuilder();
  if (c.getEnclosingClass() != null) {
    buf.append(classToString(c.getEnclosingClass())).append('.').append(c.getSimpleName());
  }
 else {
    buf.append(c.getName());
  }
  if (c.getTypeParameters().length > 0) {
    buf.append('<');
    appendAllTo(buf,"String_Node_Str",c.getTypeParameters());
    buf.append('>');
  }
  return buf.toString();
}

Fixed version (ground truth):
/** 
 * Format a   {@link Class} as a {@link String}.
 * @param c {@code Class} to format
 * @param done list of already-encountered types
 * @return String
 * @since 3.2
 */
private static String classToString(final Class<?> c,final Set<Type> done){
  final StringBuilder buf=new StringBuilder();
  if (c.getEnclosingClass() != null) {
    buf.append(classToString(c.getEnclosingClass(),done)).append('.').append(c.getSimpleName());
  }
 else {
    buf.append(c.getName());
  }
  if (c.getTypeParameters().length > 0) {
    buf.append('<');
    appendAllTo(buf,"String_Node_Str",done,c.getTypeParameters());
    buf.append('>');
  }
  return buf.toString();
}
Program: 11244
Project: 11244
Buggy source:
/** 
 * Present a given type as a Java-esque String.
 * @param type the type to create a String representation for, not{@code null}
 * @return String
 * @since 3.2
 */
public static String toString(final Type type){
  validateNotNull(type);
  if (type instanceof Class<?>) {
    return classToString((Class<?>)type);
  }
  if (type instanceof ParameterizedType) {
    return parameterizedTypeToString((ParameterizedType)type);
  }
  if (type instanceof WildcardType) {
    return wildcardTypeToString((WildcardType)type);
  }
  if (type instanceof TypeVariable<?>) {
    return typeVariableToString((TypeVariable<?>)type);
  }
  if (type instanceof GenericArrayType) {
    return genericArrayTypeToString((GenericArrayType)type);
  }
  throw new IllegalArgumentException("String_Node_Str" + type.getClass().getName());
}

Fixed version (ground truth):
private static String toString(final Type type,final Set<Type> done){
  validateNotNull(type);
  if (type instanceof Class<?>) {
    return classToString((Class<?>)type,done);
  }
  if (type instanceof ParameterizedType) {
    return parameterizedTypeToString((ParameterizedType)type,done);
  }
  if (type instanceof WildcardType) {
    return wildcardTypeToString((WildcardType)type,done);
  }
  if (type instanceof TypeVariable<?>) {
    return typeVariableToString((TypeVariable<?>)type,done);
  }
  if (type instanceof GenericArrayType) {
    return genericArrayTypeToString((GenericArrayType)type);
  }
  throw new IllegalArgumentException("String_Node_Str" + type.getClass().getName());
}
Program: 11245
Project: 11245
Buggy source:
/** 
 * Format a   {@link ParameterizedType} as a {@link String}.
 * @param p {@code ParameterizedType} to format
 * @return String
 * @since 3.2
 */
private static String parameterizedTypeToString(final ParameterizedType p){
  final StringBuilder buf=new StringBuilder();
  final Type useOwner=p.getOwnerType();
  final Class<?> raw=(Class<?>)p.getRawType();
  final Type[] typeArguments=p.getActualTypeArguments();
  if (useOwner == null) {
    buf.append(raw.getName());
  }
 else {
    if (useOwner instanceof Class<?>) {
      buf.append(((Class<?>)useOwner).getName());
    }
 else {
      buf.append(useOwner.toString());
    }
    buf.append('.').append(raw.getSimpleName());
  }
  appendAllTo(buf.append('<'),"String_Node_Str",typeArguments).append('>');
  return buf.toString();
}

Fixed version (ground truth):
/** 
 * Format a   {@link ParameterizedType} as a {@link String}.
 * @param p {@code ParameterizedType} to format
 * @param done list of already-encountered types
 * @return String
 * @since 3.2
 */
private static String parameterizedTypeToString(final ParameterizedType p,final Set<Type> done){
  final StringBuilder buf=new StringBuilder();
  final Type useOwner=p.getOwnerType();
  final Class<?> raw=(Class<?>)p.getRawType();
  final Type[] typeArguments=p.getActualTypeArguments();
  if (useOwner == null) {
    buf.append(raw.getName());
  }
 else {
    if (useOwner instanceof Class<?>) {
      buf.append(((Class<?>)useOwner).getName());
    }
 else {
      buf.append(useOwner.toString());
    }
    buf.append('.').append(raw.getSimpleName());
  }
  appendAllTo(buf.append('<'),"String_Node_Str",done,typeArguments).append('>');
  return buf.toString();
}
Program: 11246
Project: 11246
Buggy source:
private String prefKey(final ModuleItem<?> item){
  final String persistKey=item.getPersistKey();
  return persistKey == null || persistKey.isEmpty() ? persistKey : item.getName();
}

Fixed version (ground truth):
private String prefKey(final ModuleItem<?> item){
  final String persistKey=item.getPersistKey();
  return persistKey == null || persistKey.isEmpty() ? item.getName() : persistKey;
}
Program: 11247
Project: 11247
Buggy source:
@Override public void setBytes(final long startpos,final byte[] bytes,final int offset,final int length){
  checkWritePos(startpos,startpos + length);
  final int neededCapacity=(int)(Math.max(maxBufferedPos,0) + length);
  buffer.ensureCapacity(neededCapacity);
  System.arraycopy(bytes,offset,buffer.getArray(),(int)startpos,length);
  buffer.setSize(neededCapacity);
  updateMaxPos(startpos + length);
}

Fixed version (ground truth):
@Override public void setBytes(final long startpos,final byte[] bytes,final int offset,final int length){
  checkWritePos(startpos,startpos + length);
  final int neededCapacity=(int)(Math.max(maxBufferedPos,0) + length);
  buffer.ensureCapacity(neededCapacity);
  System.arraycopy(bytes,offset,buffer.getArray(),(int)startpos,length);
  buffer.setSize(neededCapacity);
  updateMaxPos(startpos + length - 1);
}
Program: 11248
Project: 11248
Buggy source:
@Override public void setByte(final long pos,final byte b){
  checkWritePos(pos,pos);
  buffer.setValue((int)pos,b);
  updateMaxPos(pos);
}

Fixed version (ground truth):
@Override public void setByte(final long pos,final byte b){
  checkWritePos(pos,pos);
  buffer.ensureCapacity((int)pos);
  if (pos == buffer.size()) {
    buffer.setSize((int)(pos + 1));
  }
  buffer.setValue((int)pos,b);
  updateMaxPos(pos);
}
Program: 11249
Project: 11249
Buggy source:
@Override public int getBytes(final long startPos,final byte[] b,final int offset,final int length){
  checkReadPos(startPos,startPos + length);
  final int readLength=(int)Math.min(getMaxPos() - startPos,length);
  System.arraycopy(buffer.getArray(),(int)startPos,b,offset,readLength);
  return readLength;
}

Fixed version (ground truth):
@Override public int getBytes(final long startPos,final byte[] b,final int offset,final int length){
  checkReadPos(startPos,startPos + length);
  final int readLength=(int)Math.min(getMaxPos() - startPos + 1,length);
  System.arraycopy(buffer.getArray(),(int)startPos,b,offset,readLength);
  return readLength;
}
Program: 11250
Project: 11250
Buggy source:
@Override public void setBytes(final long startpos,final byte[] bytes,final int offset,final int length){
  checkWritePos(startpos,startpos + length);
  final int neededCapacity=Math.max(maxBufferedPos,0) + length;
  ensureCapacity(neededCapacity);
  buffer.position((int)startpos);
  buffer.put(bytes,offset,length);
  updateMaxPos(startpos + length);
}

Fixed version (ground truth):
@Override public void setBytes(final long startpos,final byte[] bytes,final int offset,final int length){
  checkWritePos(startpos,startpos + length);
  final int neededCapacity=Math.max(maxBufferedPos,0) + length;
  ensureCapacity(neededCapacity);
  buffer.position((int)startpos);
  buffer.put(bytes,offset,length);
  updateMaxPos(startpos + length - 1);
}
Program: 11251
Project: 11251
Buggy source:
@Override public void setByte(final long pos,final byte b){
  checkWritePos(pos,pos);
  buffer.put((int)pos,b);
  updateMaxPos(pos);
}

Fixed version (ground truth):
@Override public void setByte(final long pos,final byte b){
  checkWritePos(pos,pos);
  if (pos == buffer.capacity()) {
    ensureCapacity((int)pos + 1);
  }
  buffer.put((int)pos,b);
  updateMaxPos(pos);
}
Program: 11252
Project: 11252
Buggy source:
@Override public int getBytes(final long startPos,final byte[] b,final int offset,final int length){
  checkReadPos(startPos,startPos + length);
  buffer.position((int)startPos);
  buffer.get(b,offset,length);
  return length;
}

Fixed version (ground truth):
@Override public int getBytes(final long startPos,final byte[] b,final int offset,final int length){
  checkReadPos(startPos,startPos + length);
  final int readLength=(int)Math.min(getMaxPos() - startPos + 1,length);
  buffer.position((int)startPos);
  buffer.get(b,offset,readLength);
  return readLength;
}
Program: 11253
Project: 11253
Buggy source:
/** 
 * Tests   {@link BytesLocation#BytesLocation(byte[],int,int)}. 
 */
@Test public void testBytesOffsetLength(){
  final byte[] digits={3,1,4,1,5,9,2,6,5,3,5,8,9,7,9};
  final int offset=3, length=5;
  final BytesLocation loc=new BytesLocation(digits,offset,length);
  final byte[] testDigits=new byte[digits.length];
  loc.getByteBank().getBytes(0,testDigits);
  assertEquals(length,loc.getByteBank().getMaxPos());
  final byte[] expectedDigits=new byte[digits.length];
  System.arraycopy(digits,offset,expectedDigits,0,length);
  assertArrayEquals(expectedDigits,testDigits);
}

Fixed version (ground truth):
/** 
 * Tests   {@link BytesLocation#BytesLocation(byte[],int,int)}. 
 */
@Test public void testBytesOffsetLength(){
  final byte[] digits={3,1,4,1,5,9,2,6,5,3,5,8,9,7,9};
  final int offset=3, length=5;
  final BytesLocation loc=new BytesLocation(digits,offset,length);
  final byte[] testDigits=new byte[digits.length];
  loc.getByteBank().getBytes(0,testDigits);
  assertEquals(length - 1,loc.getByteBank().getMaxPos());
  final byte[] expectedDigits=new byte[digits.length];
  System.arraycopy(digits,offset,expectedDigits,0,length);
  assertArrayEquals(expectedDigits,testDigits);
}
Program: 11254
Project: 11254
Buggy source:
/** 
 * Loads the index of all classes annotated with the specified annotation. <p> </p>
 * @param annotation the annotation type
 * @param loader the class loader to use when loading {@link Class}-type annotation fields
 * @return the index
 */
public static <A extends Annotation>Index<A> load(final Class<A> annotation,final ClassLoader loader){
  EclipseHelper.updateAnnotationIndex(loader);
  return new Index<>(annotation,loader);
}

Fixed version (ground truth):
/** 
 * Loads the index of all classes annotated with the specified annotation.
 * @param annotation the annotation type
 * @param loader the class loader to use when loading {@link Class}-type annotation fields
 * @return the index
 */
public static <A extends Annotation>Index<A> load(final Class<A> annotation,final ClassLoader loader){
  EclipseHelper.updateAnnotationIndex(loader);
  return new Index<>(annotation,loader);
}
Program: 11255
Project: 11255
Buggy source:
/** 
 * @see #supports(ConversionRequest)
 * @deprecated Use {@link #supports(Object,Type)}
 */
@Deprecated boolean supports(Class<?> src,Type dest);

Fixed version (ground truth):
/** 
 * @see HandlerService#supports(Object)
 * @deprecated Use {@link #supports(Object,Type)}
 */
@Deprecated boolean supports(Class<?> src,Type dest);
Program: 11256
Project: 11256
Buggy source:
/** 
 * @see #getHandler(ConversionRequest)
 * @deprecated Use {@link #getHandler(Object,Type)}
 */
@Deprecated Converter<?,?> getHandler(Class<?> src,Type dest);

Fixed version (ground truth):
/** 
 * @see HandlerService#getHandler(Object)
 * @deprecated Use {@link #getHandler(Object,Type)}
 */
@Deprecated Converter<?,?> getHandler(Class<?> src,Type dest);
Program: 11257
Project: 11257
Buggy source:
/** 
 * Gets how deep into the menu structure this node is. For example, "File" would be at depth 1, whereas "Exit" (of "File>Exit") would be at depth 2.
 */
public int getMenuDepth(){
  return menuDepth;
}

Fixed version (ground truth):
/** 
 * Gets how deep into the menu structure this node is. For example, "File" would be at depth 1, whereas "Exit" (of "File&gt;Exit") would be at depth 2.
 */
public int getMenuDepth(){
  return menuDepth;
}
Program: 11260
Project: 11260
Buggy source:
/** 
 * Returns the class of the caller (excluding the specified class). <p> Sometimes it is convenient to determine the caller's context, e.g. to determine whether running in a maven-surefire-plugin context (in which case the location of the caller's class would end in <i>target/test-classes/</i>). </p>
 * @param excluding the class to exclude (or null)
 * @return the class of the caller
 */
public static Class<?> getCallingClass(final Class<?> excluding){
  return getCallingCodeLocation(excluding).getKey();
}

Fixed version (ground truth):
/** 
 * Returns the class of the caller (excluding the specified class). <p> Sometimes it is convenient to determine the caller's context, e.g. to determine whether running in a maven-surefire-plugin context (in which case the location of the caller's class would end in  {@code target/test-classes/}). </p>
 * @param excluding the class to exclude (or null)
 * @return the class of the caller
 */
public static Class<?> getCallingClass(final Class<?> excluding){
  return getCallingCodeLocation(excluding).getKey();
}
Program: 11262
Project: 11262
Buggy source:
/** 
 * Checks a <i>.jar</i> file for stale annotations. <p> This method is broken at the moment since there is no good way to verify that SezPoz ran before the <i>.jar</i> file was packaged. </p>
 * @param file the <i>.jar</i> file
 * @see EclipseHelper
 */
@Deprecated public static void checkJar(final File file) throws IOException {
  check(file);
}

Fixed version (ground truth):
/** 
 * Checks a   {@code .jar} file for stale annotations.<p> This method is broken at the moment since there is no good way to verify that SezPoz ran before the  {@code .jar} file was packaged.</p>
 * @param file the {@code .jar} file
 * @see EclipseHelper
 */
@Deprecated public static void checkJar(final File file) throws IOException {
  check(file);
}
Program: 11263
Project: 11263
Buggy source:
/** 
 * Writes out a DOM as <i>.xml</i> file.
 * @param xml the DOM
 * @param file the file to write
 * @throws TransformerException
 */
@Deprecated public static void writeXMLFile(final Document xml,final File file) throws TransformerException {
  final Source source=new DOMSource(xml);
  final Result result=new StreamResult(file);
  final TransformerFactory factory=TransformerFactory.newInstance();
  final Transformer transformer=factory.newTransformer();
  transformer.setOutputProperty(OutputKeys.INDENT,"String_Node_Str");
  transformer.setOutputProperty("String_Node_Str","String_Node_Str");
  transformer.transform(source,result);
}

Fixed version (ground truth):
/** 
 * Writes out a DOM as   {@code .xml} file.
 * @param xml the DOM
 * @param file the file to write
 * @throws TransformerException
 */
@Deprecated public static void writeXMLFile(final Document xml,final File file) throws TransformerException {
  final Source source=new DOMSource(xml);
  final Result result=new StreamResult(file);
  final TransformerFactory factory=TransformerFactory.newInstance();
  final Transformer transformer=factory.newTransformer();
  transformer.setOutputProperty(OutputKeys.INDENT,"String_Node_Str");
  transformer.setOutputProperty("String_Node_Str","String_Node_Str");
  transformer.transform(source,result);
}
Program: 11264
Project: 11264
Buggy source:
/** 
 * Checks whether the annotations are possibly out-of-date. <p> This method looks whether there are any <i>.class</i> files older than their corresponding <i>.java</i> files, or whether there are <i>.class</i> files that were generated since last time we checked. </p>
 * @param classes the <i>classes/</i> directory where Maven puts the<i>.class</i> files
 * @param source the <i>src/main/java/<i> directory where Maven expects the<i>.java</i> files
 * @param youngerThan the date/time when we last checked
 * @see EclipseHelper
 */
@Deprecated public static boolean checkDirectory(final File classes,final File source,final long youngerThan) throws IOException {
  return check(classes);
}

Fixed version (ground truth):
/** 
 * Checks whether the annotations are possibly out-of-date. <p> This method looks whether there are any   {@code .class} files older thantheir corresponding  {@code .java} files, or whether there are{@code .class} files that were generated since last time we checked.</p>
 * @param classes the {@code classes/} directory where Maven puts the{@code .class} files
 * @param source the {@code src/main/java/} directory where Maven expects the{@code .java} files
 * @param youngerThan the date/time when we last checked
 * @see EclipseHelper
 */
@Deprecated public static boolean checkDirectory(final File classes,final File source,final long youngerThan) throws IOException {
  return check(classes);
}
Program: 11265
Project: 11265
Buggy source:
private <T>void addItem(final String name,final Class<T> type,final Map<String,Object> attrs){
  final DefaultMutableModuleItem<T> item=new DefaultMutableModuleItem<>(this,name,type);
  for (  final String key : attrs.keySet()) {
    final Object value=attrs.get(key);
    assignAttribute(item,key,value);
  }
  if (item.isInput())   registerInput(item);
  if (item.isOutput()) {
    registerOutput(item);
    appendReturnValue=false;
  }
}

Fixed version (ground truth):
private <T>void addItem(final String name,final Class<T> type,final Map<String,Object> attrs,final boolean explicit){
  final DefaultMutableModuleItem<T> item=new DefaultMutableModuleItem<>(this,name,type);
  for (  final String key : attrs.keySet()) {
    final Object value=attrs.get(key);
    assignAttribute(item,key,value);
  }
  if (item.isInput())   registerInput(item);
  if (item.isOutput()) {
    registerOutput(item);
    if (explicit)     appendReturnValue=false;
  }
}
Program: 11266
Project: 11266
Buggy source:
/** 
 * Adds an output for the value returned by the script itself. 
 */
private void addReturnValue(){
  final HashMap<String,Object> attrs=new HashMap<>();
  attrs.put("String_Node_Str","String_Node_Str");
  addItem(ScriptModule.RETURN_VALUE,Object.class,attrs);
}

Fixed version (ground truth):
/** 
 * Adds an output for the value returned by the script itself. 
 */
private void addReturnValue(){
  final HashMap<String,Object> attrs=new HashMap<>();
  attrs.put("String_Node_Str","String_Node_Str");
  addItem(ScriptModule.RETURN_VALUE,Object.class,attrs,false);
}
Program: 11267
Project: 11267
Buggy source:
private void parseParam(final String param,final Map<String,Object> attrs) throws ScriptException {
  final String[] tokens=param.trim().split("String_Node_Str");
  checkValid(tokens.length >= 1,param);
  final String typeName, varName;
  if (isIOType(tokens[0])) {
    checkValid(tokens.length >= 3,param);
    attrs.put("String_Node_Str",tokens[0]);
    typeName=tokens[1];
    varName=tokens[2];
  }
 else {
    checkValid(tokens.length >= 2,param);
    typeName=tokens[0];
    varName=tokens[1];
  }
  final Class<?> type=scriptService.lookupClass(typeName);
  addItem(varName,type,attrs);
  if (ScriptModule.RETURN_VALUE.equals(varName)) {
    appendReturnValue=false;
  }
}

Fixed version (ground truth):
private void parseParam(final String param,final Map<String,Object> attrs) throws ScriptException {
  final String[] tokens=param.trim().split("String_Node_Str");
  checkValid(tokens.length >= 1,param);
  final String typeName, varName;
  if (isIOType(tokens[0])) {
    checkValid(tokens.length >= 3,param);
    attrs.put("String_Node_Str",tokens[0]);
    typeName=tokens[1];
    varName=tokens[2];
  }
 else {
    checkValid(tokens.length >= 2,param);
    typeName=tokens[0];
    varName=tokens[1];
  }
  final Class<?> type=scriptService.lookupClass(typeName);
  addItem(varName,type,attrs,true);
  if (ScriptModule.RETURN_VALUE.equals(varName)) {
    appendReturnValue=false;
  }
}
Program: 11268
Project: 11268
Buggy source:
@Override public void handle(final LinkedList<String> args){
  if (!supports(args))   return;
  args.removeFirst();
  final String code=args.removeFirst();
  final String arg=getParam(args);
  try {
    if (arg == null)     runService.run(code);
 else {
      final Items items=parser.parse(arg);
      if (items.isMap())       runService.run(code,items.asMap());
 else       if (items.isList())       runService.run(code,items.toArray());
 else {
        throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
      }
    }
  }
 catch (  final InvocationTargetException exc) {
    throw new RuntimeException(exc);
  }
}

Fixed version (ground truth):
@Override public void handle(final LinkedList<String> args){
  if (!supports(args))   return;
  args.removeFirst();
  final String code=args.removeFirst();
  final String arg=getParam(args);
  if (arg != null)   args.removeFirst();
  try {
    if (arg == null)     runService.run(code);
 else {
      final Items items=parser.parse(arg);
      if (items.isMap())       runService.run(code,items.asMap());
 else       if (items.isList())       runService.run(code,items.toArray());
 else {
        throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
      }
    }
  }
 catch (  final InvocationTargetException exc) {
    throw new RuntimeException(exc);
  }
}
Program: 11269
Project: 11269
Buggy source:
@Override public String getShortName(){
  return getClass().getName().toLowerCase();
}

Fixed version (ground truth):
@Override public String getShortName(){
  return getClass().getSimpleName().toLowerCase();
}
Program: 11270
Project: 11270
Buggy source:
@Override public void cancel(final String reason){
  cancelReason=reason == null ? "String_Node_Str" : reason;
  if (command instanceof Cancelable) {
    ((Cancelable)command).cancel(reason);
  }
}

Fixed version (ground truth):
@Override public void cancel(final String reason){
  if (command instanceof Cancelable) {
    ((Cancelable)command).cancel(reason);
    return;
  }
  cancelReason=reason == null ? "String_Node_Str" : reason;
}
Program: 11271
Project: 11271
Buggy source:
@Override public String getCancelReason(){
  return cancelReason;
}

Fixed version (ground truth):
@Override public String getCancelReason(){
  if (command instanceof Cancelable) {
    return ((Cancelable)command).getCancelReason();
  }
  return cancelReason;
}
Program: 11272
Project: 11272
Buggy source:
@Override public boolean isCanceled(){
  return cancelReason != null;
}

Fixed version (ground truth):
@Override public boolean isCanceled(){
  if (command instanceof Cancelable) {
    return ((Cancelable)command).isCanceled();
  }
  return cancelReason != null;
}
Program: 11273
Project: 11273
Buggy source:
/** 
 * Initializes   {@link #scriptLanguageIndex}. 
 */
private synchronized void initScriptLanguageIndex(){
  if (scriptLanguageIndex != null)   return;
  final ScriptLanguageIndex index=new ScriptLanguageIndex(log);
  for (  final ScriptLanguage language : getInstances()) {
    index.add(language,false);
  }
  final ScriptEngineManager manager=new ScriptEngineManager();
  for (  final ScriptEngineFactory factory : manager.getEngineFactories()) {
    index.add(factory,true);
  }
  scriptLanguageIndex=index;
}

Fixed version (ground truth):
/** 
 * Initializes   {@link #scriptLanguageIndex}. 
 */
private synchronized void initScriptLanguageIndex(){
  if (scriptLanguageIndex != null)   return;
  final ScriptLanguageIndex index=new ScriptLanguageIndex(log);
  for (  final ScriptLanguage language : getInstances()) {
    index.add(language,false);
  }
  final ScriptEngineManager manager=new ScriptEngineManager();
  for (  final ScriptEngineFactory factory : manager.getEngineFactories()) {
    index.add(factory,true);
  }
  for (  final ScriptLanguage language : index) {
    if (language.getContext() == null)     language.setContext(getContext());
  }
  scriptLanguageIndex=index;
}
Program: 11274
Project: 11274
Buggy source:
/** 
 * @see java.util.prefs.Preferences#keys() 
 */
public String[] keys(){
  try {
    return p.keys();
  }
 catch (  final java.util.prefs.BackingStoreException exc) {
    log.error(exc);
    return new String[0];
  }
}

Fixed version (ground truth):
/** 
 * @see java.util.prefs.Preferences#keys() 
 */
public String[] keys(){
  try {
    final String[] keys=p.keys();
    for (int i=0; i < keys.length; i++) {
      keys[i]=safeKey(keys[i]);
    }
    return keys;
  }
 catch (  final java.util.prefs.BackingStoreException exc) {
    log.error(exc);
    return new String[0];
  }
}
Program: 11275
Project: 11275
Buggy source:
/** 
 * @see java.util.prefs.Preferences#getDouble(String,double) 
 */
public double getDouble(final String key,final double def){
  return p.getDouble(key,def);
}

Fixed version (ground truth):
/** 
 * @see java.util.prefs.Preferences#getDouble(String,double) 
 */
public double getDouble(final String key,final double def){
  return p.getDouble(safeKey(key),def);
}
Program: 11276
Project: 11276
Buggy source:
/** 
 * @see java.util.prefs.Preferences#putDouble(String,double) 
 */
public void putDouble(final String key,final double value){
  p.putDouble(key,value);
}

Fixed version (ground truth):
/** 
 * @see java.util.prefs.Preferences#putDouble(String,double) 
 */
public void putDouble(final String key,final double value){
  p.putDouble(safeKey(key),value);
}
Program: 11277
Project: 11277
Buggy source:
/** 
 * @see java.util.prefs.Preferences#getFloat(String,float) 
 */
public float getFloat(final String key,final float def){
  return p.getFloat(key,def);
}

Fixed version (ground truth):
/** 
 * @see java.util.prefs.Preferences#getFloat(String,float) 
 */
public float getFloat(final String key,final float def){
  return p.getFloat(safeKey(key),def);
}
Program: 11278
Project: 11278
Buggy source:
/** 
 * @see java.util.prefs.Preferences#putLong(String,long) 
 */
public void putLong(final String key,final long value){
  p.putLong(key,value);
}

Fixed version (ground truth):
/** 
 * @see java.util.prefs.Preferences#putLong(String,long) 
 */
public void putLong(final String key,final long value){
  p.putLong(safeKey(key),value);
}
Program: 11279
Project: 11279
Buggy source:
/** 
 * @see java.util.prefs.Preferences#put 
 */
public void put(final String key,final Object value){
  p.put(key,value == null ? null : value.toString());
}

Fixed version (ground truth):
/** 
 * @see java.util.prefs.Preferences#put 
 */
public void put(final String key,final Object value){
  p.put(safeKey(key),value == null ? null : value.toString());
}
Program: 11280
Project: 11280
Buggy source:
/** 
 * @see java.util.prefs.Preferences#get(String,String) 
 */
public String get(final String key,final String def){
  return p.get(key,def);
}

Fixed version (ground truth):
/** 
 * @see java.util.prefs.Preferences#get(String,String) 
 */
public String get(final String key,final String def){
  return p.get(safeKey(key),def);
}
Program: 11281
Project: 11281
Buggy source:
/** 
 * @see java.util.prefs.Preferences#getFloat(String,float) 
 */
public boolean getBoolean(final String key,final boolean def){
  return p.getBoolean(key,def);
}

Fixed version (ground truth):
/** 
 * @see java.util.prefs.Preferences#getFloat(String,float) 
 */
public boolean getBoolean(final String key,final boolean def){
  return p.getBoolean(safeKey(key),def);
}
Program: 11282
Project: 11282
Buggy source:
/** 
 * @see java.util.prefs.Preferences#putBoolean(String,boolean) 
 */
public void putBoolean(final String key,final boolean value){
  p.putBoolean(key,value);
}

Fixed version (ground truth):
/** 
 * @see java.util.prefs.Preferences#putBoolean(String,boolean) 
 */
public void putBoolean(final String key,final boolean value){
  p.putBoolean(safeKey(key),value);
}
Program: 11283
Project: 11283
Buggy source:
/** 
 * @see java.util.prefs.Preferences#putInt(String,int) 
 */
public void putInt(final String key,final int value){
  p.putInt(key,value);
}

Fixed version (ground truth):
/** 
 * @see java.util.prefs.Preferences#putInt(String,int) 
 */
public void putInt(final String key,final int value){
  p.putInt(safeKey(key),value);
}
Program: 11284
Project: 11284
Buggy source:
/** 
 * @see java.util.prefs.Preferences#getLong(String,long) 
 */
public long getLong(final String key,final long def){
  return p.getLong(key,def);
}

Fixed version (ground truth):
/** 
 * @see java.util.prefs.Preferences#getLong(String,long) 
 */
public long getLong(final String key,final long def){
  return p.getLong(safeKey(key),def);
}
Program: 11285
Project: 11285
Buggy source:
/** 
 * @see java.util.prefs.Preferences#getInt(String,int) 
 */
public int getInt(final String key,final int def){
  return p.getInt(key,def);
}

Fixed version (ground truth):
/** 
 * @see java.util.prefs.Preferences#getInt(String,int) 
 */
public int getInt(final String key,final int def){
  return p.getInt(safeKey(key),def);
}
Program: 11286
Project: 11286
Buggy source:
/** 
 * @see java.util.prefs.Preferences#putFloat(String,float) 
 */
public void putFloat(final String key,final float value){
  p.putFloat(key,value);
}

Fixed version (ground truth):
/** 
 * @see java.util.prefs.Preferences#putFloat(String,float) 
 */
public void putFloat(final String key,final float value){
  p.putFloat(safeKey(key),value);
}
Program: 11287
Project: 11287
Buggy source:
private <T>void assignDefaultValue(final Module module,final ModuleItem<T> item){
  if (module.isResolved(item.getName()))   return;
  final T defaultValue=moduleService.getDefaultValue(item);
  if (defaultValue == null)   return;
  item.setValue(module,defaultValue);
}

Fixed version (ground truth):
private <T>void assignDefaultValue(final Module module,final ModuleItem<T> item){
  if (module.isResolved(item.getName()))   return;
  final T nullValue=ConversionUtils.getNullValue(item.getType());
  if (MiscUtils.equal(item.getValue(module),nullValue))   return;
  final T defaultValue=moduleService.getDefaultValue(item);
  if (defaultValue == null)   return;
  item.setValue(module,defaultValue);
}
Program: 11288
Project: 11288
Buggy source:
@Override public Number getStepSize(){
  return tValue(getParameter().stepSize(),Number.class);
}

Fixed version (ground truth):
@Override public Number getStepSize(){
  final String value=getParameter().stepSize();
  try {
    final double stepSize=Double.parseDouble(value);
    return stepSize;
  }
 catch (  final NumberFormatException exc) {
    return tValue(value,Number.class);
  }
}
Program: 11289
Project: 11289
Buggy source:
/** 
 * Gets the reader which delivers the script's content. <p> This might be null, in which case the content is stored in a file on disk given by   {@link #getPath()}. </p>
 */
public BufferedReader getReader(){
  return reader;
}

Fixed version (ground truth):
/** 
 * Gets a reader which delivers the script's content. <p> This might be null, in which case the content is stored in a file on disk given by   {@link #getPath()}. </p>
 */
public BufferedReader getReader(){
  if (script == null) {
    return null;
  }
  return new BufferedReader(new StringReader(script),PARAM_CHAR_MAX);
}
Program: 11290
Project: 11290
Buggy source:
/** 
 * Creates a script metadata object which describes a script provided by the given   {@link Reader}.
 * @param context The SciJava application context to use when populatingservice inputs.
 * @param path Pseudo-path to the script file. This file does not actuallyneed to exist, but rather provides a name for the script with file extension.
 * @param reader Reader which provides the script itself (i.e., its contents).
 */
public ScriptInfo(final Context context,final String path,final Reader reader){
  setContext(context);
  this.path=path;
  this.reader=reader == null ? null : new BufferedReader(reader,PARAM_CHAR_MAX);
}

Fixed version (ground truth):
/** 
 * Creates a script metadata object which describes a script provided by the given   {@link Reader}.
 * @param context The SciJava application context to use when populatingservice inputs.
 * @param path Pseudo-path to the script file. This file does not actuallyneed to exist, but rather provides a name for the script with file extension.
 * @param reader Reader which provides the script itself (i.e., its contents).
 */
public ScriptInfo(final Context context,final String path,final Reader reader){
  setContext(context);
  this.path=path;
  String script=null;
  if (reader != null) {
    try {
      script=getReaderContentsAsString(reader);
    }
 catch (    final IOException exc) {
      log.error("String_Node_Str" + path,exc);
    }
  }
  this.script=script;
}
Program: 11292
Project: 11292
Buggy source:
/** 
 * Creates an XML object for an existing document. 
 */
public XML(final String path,final Document doc){
  this.path=path;
  this.doc=doc;
  if (debug) {
    System.err.println(ClassUtils.getLocation(XPathFactory.class));
  }
  XPath xpath=null;
  final Thread thread=Thread.currentThread();
  final ClassLoader contextClassLoader=thread.getContextClassLoader();
  try {
    ClassLoader loader=contextClassLoader;
    for (; ; )     try {
      xpath=XPathFactory.newInstance().newXPath();
      try {
        xpath.evaluate("String_Node_Str",doc);
      }
 catch (      Throwable t) {
        if (debug) {
          System.err.println("String_Node_Str" + xpath.getClass() + "String_Node_Str"+ ClassUtils.getLocation(xpath.getClass())+ "String_Node_Str");
          t.printStackTrace();
        }
        throw new Error(t);
      }
      break;
    }
 catch (    Error e) {
      if (debug)       e.printStackTrace();
      loader=loader.getParent();
      if (loader == null)       throw e;
      thread.setContextClassLoader(loader);
    }
    this.xpath=xpath;
  }
  finally {
    thread.setContextClassLoader(contextClassLoader);
  }
}

Fixed version (ground truth):
/** 
 * Creates an XML object for an existing document. 
 */
public XML(final String path,final Document doc){
  this.path=path;
  this.doc=doc;
  if (debug) {
    System.err.println(ClassUtils.getLocation(XPathFactory.class));
  }
  XPath xp=null;
  final Thread thread=Thread.currentThread();
  final ClassLoader contextClassLoader=thread.getContextClassLoader();
  try {
    ClassLoader loader=contextClassLoader;
    while (true) {
      try {
        xp=XPathFactory.newInstance().newXPath();
        try {
          xp.evaluate("String_Node_Str",doc);
        }
 catch (        Throwable t) {
          if (debug) {
            System.err.println("String_Node_Str" + xp.getClass() + "String_Node_Str"+ ClassUtils.getLocation(xp.getClass())+ "String_Node_Str");
            t.printStackTrace();
          }
          throw new Error(t);
        }
        break;
      }
 catch (      Error e) {
        if (debug)         e.printStackTrace();
        loader=loader.getParent();
        if (loader == null)         throw e;
        thread.setContextClassLoader(loader);
      }
    }
    xpath=xp;
  }
  finally {
    thread.setContextClassLoader(contextClassLoader);
  }
}
Program: 11293
Project: 11293
Buggy source:
@Override public <D extends DT>PT create(final D data){
  final PT instance=findWrapper(data);
  if (instance == null) {
    throw new IllegalArgumentException("String_Node_Str" + getPluginType().getSimpleName() + "String_Node_Str"+ data);
  }
  return instance;
}

Fixed version (ground truth):
@Override public <D extends DT>PT create(final D data){
  final PT instance=findWrapper(data);
  if (instance == null) {
    throw new IllegalArgumentException("String_Node_Str" + getPluginType().getSimpleName() + "String_Node_Str"+ data);
  }
  instance.set(data);
  return instance;
}
Program: 11294
Project: 11294
Buggy source:
/** 
 * Persist the history.
 * @see {@link Prefs}
 */
public void write(){
  prefs.putIterable(getClass(),entries,PREFIX + name);
}

Fixed version (ground truth):
/** 
 * Persist the history.
 * @see PrefService
 */
public void write(){
  prefs.putIterable(getClass(),entries,PREFIX + name);
}
Program: 11296
Project: 11296
Buggy source:
private synchronized void initInstances(){
  if (instances != null)   return;
  final List<PT> list=Collections.unmodifiableList(filterInstances(getPluginService().createInstancesOfType(getPluginType())));
  final HashMap<Class<? extends PT>,PT> map=new HashMap<Class<? extends PT>,PT>();
  for (  final PT plugin : instances) {
    @SuppressWarnings("String_Node_Str") final Class<? extends PT> ptClass=(Class<? extends PT>)plugin.getClass();
    map.put(ptClass,plugin);
  }
  log.info("String_Node_Str" + list.size() + "String_Node_Str"+ getPluginType().getSimpleName()+ "String_Node_Str");
  instanceMap=map;
  instances=list;
}

Fixed version (ground truth):
private synchronized void initInstances(){
  if (instances != null)   return;
  final List<PT> list=Collections.unmodifiableList(filterInstances(getPluginService().createInstancesOfType(getPluginType())));
  final HashMap<Class<? extends PT>,PT> map=new HashMap<Class<? extends PT>,PT>();
  for (  final PT plugin : list) {
    @SuppressWarnings("String_Node_Str") final Class<? extends PT> ptClass=(Class<? extends PT>)plugin.getClass();
    map.put(ptClass,plugin);
  }
  log.info("String_Node_Str" + list.size() + "String_Node_Str"+ getPluginType().getSimpleName()+ "String_Node_Str");
  instanceMap=map;
  instances=list;
}