nus-yam/ex-repair huggingface dataset:
Program: 59956
Project: 59956
Buggy source:
/** 
 * Reads a short value from a byte buffer.
 * @param buffer the buffer to read from.
 * @return a short value
 */
public static short readShort(byte[] buffer){
  return (short)(((buffer[0] & 0xff)) | ((buffer[1] & 0xff) << 8));
}

Fixed version (ground truth):
/** 
 * Reads a short value from a byte buffer.
 * @param buffer the buffer to read from.
 * @return a short value
 */
public static short readShort(byte[] buffer){
  return (short)(((buffer[1] & 0xff)) | ((buffer[0] & 0xff) << 8));
}
Program: 59957
Project: 59957
Buggy source:
@Override public void onRecord(int tag,int timestamp,int length,HprofReader reader) throws IOException {
  if (!readObjects) {
switch (tag) {
case Tag.STRING:
      HprofString string=reader.readStringRecord(length,timestamp);
    stringIds.put(string.getId(),nextStringId);
  string.setId(nextStringId);
nextStringId++;
writer.writeString(string,true);
break;
case Tag.LOAD_CLASS:
ClassDefinition classDef=reader.readLoadClassRecord();
classesByOriginalId.put(classDef.getObjectId(),classDef);
break;
case Tag.HEAP_DUMP:
case Tag.HEAP_DUMP_SEGMENT:
ClassDumpProcessor dumpProcessor=new ClassDumpProcessor();
HeapDumpReader dumpReader=new HeapDumpReader(reader.getInputStream(),length,dumpProcessor);
while (dumpReader.hasNext()) {
dumpReader.next();
}
break;
case Tag.UNLOAD_CLASS:
case Tag.HEAP_DUMP_END:
super.onRecord(tag,timestamp,length,reader);
break;
default :
byte[] data=read(reader.getInputStream(),length);
writer.writeLegacyRecord(tag,data);
break;
}
}
 else {
switch (tag) {
case Tag.HEAP_DUMP:
case Tag.HEAP_DUMP_SEGMENT:
ObjectDumpProcessor dumpProcessor=new ObjectDumpProcessor();
HeapDumpReader dumpReader=new HeapDumpReader(reader.getInputStream(),length,dumpProcessor);
while (dumpReader.hasNext()) {
dumpReader.next();
}
break;
default :
super.onRecord(tag,timestamp,length,reader);
}
}
}

Fixed version (ground truth):
@Override public void onRecord(int tag,int timestamp,int length,HprofReader reader) throws IOException {
  if (!readObjects) {
switch (tag) {
case Tag.STRING:
      HprofString string=reader.readStringRecord(length,timestamp);
    stringIds.put(string.getId(),nextStringId);
  string.setId(nextStringId);
nextStringId++;
boolean hashed=!(string.getValue().startsWith("String_Node_Str"));
writer.writeString(string,hashed);
break;
case Tag.LOAD_CLASS:
ClassDefinition classDef=reader.readLoadClassRecord();
classesByOriginalId.put(classDef.getObjectId(),classDef);
break;
case Tag.HEAP_DUMP:
case Tag.HEAP_DUMP_SEGMENT:
ClassDumpProcessor dumpProcessor=new ClassDumpProcessor();
HeapDumpReader dumpReader=new HeapDumpReader(reader.getInputStream(),length,dumpProcessor);
while (dumpReader.hasNext()) {
dumpReader.next();
}
break;
case Tag.UNLOAD_CLASS:
case Tag.HEAP_DUMP_END:
super.onRecord(tag,timestamp,length,reader);
break;
default :
byte[] data=read(reader.getInputStream(),length);
writer.writeLegacyRecord(tag,data);
break;
}
}
 else {
switch (tag) {
case Tag.HEAP_DUMP:
case Tag.HEAP_DUMP_SEGMENT:
ObjectDumpProcessor dumpProcessor=new ObjectDumpProcessor();
HeapDumpReader dumpReader=new HeapDumpReader(reader.getInputStream(),length,dumpProcessor);
while (dumpReader.hasNext()) {
dumpReader.next();
}
break;
default :
super.onRecord(tag,timestamp,length,reader);
}
}
}
Program: 59958
Project: 59958
Buggy source:
private int mapObjectId(int id){
  if (!objectIds.containsKey(id)) {
    mappedIds.add(nextObjectId);
    objectIds.put(id,nextObjectId);
    nextObjectId++;
  }
  if (mappedIds.contains(id)) {
    throw new IllegalArgumentException("String_Node_Str" + id);
  }
  return objectIds.get(id);
}

Fixed version (ground truth):
private int mapObjectId(int id){
  if (id == 0) {
    return 0;
  }
  if (!objectIds.containsKey(id)) {
    mappedIds.add(nextObjectId);
    objectIds.put(id,nextObjectId);
    nextObjectId++;
  }
  if (mappedIds.contains(id)) {
    throw new IllegalArgumentException("String_Node_Str" + id);
  }
  return objectIds.get(id);
}
Program: 59959
Project: 59959
Buggy source:
private void verifySuperClass(ClassDefinition cls){
  int superId=cls.getSuperClassObjectId();
  if (classes.containsKey(superId)) {
    verifySuperClass(classes.get(superId));
  }
 else {
    throw new IllegalStateException("String_Node_Str" + strings.get(cls.getNameStringId()) + "String_Node_Str"+ superId+ "String_Node_Str");
  }
}

Fixed version (ground truth):
private void verifySuperClass(ClassDefinition cls){
  int superId=cls.getSuperClassObjectId();
  String className=strings.get(cls.getNameStringId());
  if (classes.containsKey(superId)) {
    verifySuperClass(classes.get(superId));
  }
 else   if (!className.equals("String_Node_Str")) {
    throw new IllegalStateException("String_Node_Str" + className + "String_Node_Str"+ superId+ "String_Node_Str");
  }
}
Program: 59960
Project: 59960
Buggy source:
private void readObjectArray(InputStream in) throws IOException {
  int originalObjectId=readInt(in);
  in.skip(4);
  int count=readInt(in);
  int originalElementClassId=readInt(in);
  int[] elements=new int[count];
  for (int i=0; i < count; i++) {
    elements[i]=readInt(in);
  }
  writer.writeObjectArray(originalObjectId,originalElementClassId,elements);
}

Fixed version (ground truth):
private void readObjectArray(InputStream in) throws IOException {
  int originalObjectId=readInt(in);
  skip(in,4);
  int count=readInt(in);
  int originalElementClassId=readInt(in);
  int[] elements=new int[count];
  for (int i=0; i < count; i++) {
    elements[i]=readInt(in);
  }
  writer.writeObjectArray(originalObjectId,originalElementClassId,elements);
}
Program: 59961
Project: 59961
Buggy source:
public void writeInstanceDump(Instance instance) throws IOException {
  writeInt32(BmdTag.INSTANCE_DUMP);
  writeInt32(mapObjectId(instance.getObjectId()));
  writeInt32(mapObjectId(instance.getClassObjectId()));
  ClassDefinition currentClass=classesByOriginalId.get(instance.getClassObjectId());
  ByteArrayInputStream in=new ByteArrayInputStream(instance.getInstanceFieldData());
  while (currentClass != null) {
    int fieldCount=currentClass.getInstanceFields().size();
    for (int i=0; i < fieldCount; i++) {
      InstanceField field=currentClass.getInstanceFields().get(i);
      BasicType type=field.getType();
      if (type == BasicType.OBJECT) {
        int id=readInt(in);
        writeInt32(mapObjectId(id));
      }
 else {
        in.skip(type.size);
      }
    }
    currentClass=classesByOriginalId.get(currentClass.getSuperClassObjectId());
  }
  if (in.available() != 0) {
    throw new IllegalStateException("String_Node_Str" + in.available());
  }
}

Fixed version (ground truth):
public void writeInstanceDump(Instance instance) throws IOException {
  writeInt32(BmdTag.INSTANCE_DUMP);
  writeInt32(mapObjectId(instance.getObjectId()));
  writeInt32(mapObjectId(instance.getClassObjectId()));
  ClassDefinition currentClass=classesByOriginalId.get(instance.getClassObjectId());
  ByteArrayInputStream in=new ByteArrayInputStream(instance.getInstanceFieldData());
  while (currentClass != null) {
    int fieldCount=currentClass.getInstanceFields().size();
    for (int i=0; i < fieldCount; i++) {
      InstanceField field=currentClass.getInstanceFields().get(i);
      BasicType type=field.getType();
      if (type == BasicType.OBJECT) {
        int id=readInt(in);
        writeInt32(mapObjectId(id));
      }
 else {
        skip(in,type.size);
      }
    }
    currentClass=classesByOriginalId.get(currentClass.getSuperClassObjectId());
  }
  if (in.available() != 0) {
    throw new IllegalStateException("String_Node_Str" + in.available());
  }
}
Program: 59962
Project: 59962
Buggy source:
private void readPrimitiveArray(InputStream in) throws IOException {
  int originalObjectId=readInt(in);
  in.skip(4);
  int count=readInt(in);
  BasicType type=BasicType.fromType(in.read());
  in.skip(count * type.size);
  writer.writePrimitiveArray(originalObjectId,type,count);
}

Fixed version (ground truth):
private void readPrimitiveArray(InputStream in) throws IOException {
  int originalObjectId=readInt(in);
  skip(in,4);
  int count=readInt(in);
  BasicType type=BasicType.fromType(in.read());
  skip(in,count * type.size);
  writer.writePrimitiveArray(originalObjectId,type,count);
}
Program: 59963
Project: 59963
Buggy source:
@Override public void onHeapRecord(int tag,HeapDumpReader reader) throws IOException {
  InputStream in=reader.getInputStream();
switch (tag) {
case HeapTag.INSTANCE_DUMP:
    Instance instance=reader.readInstanceDump();
  writer.writeInstanceDump(instance);
break;
case HeapTag.OBJECT_ARRAY_DUMP:
readObjectArray(in);
break;
case HeapTag.PRIMITIVE_ARRAY_DUMP:
readPrimitiveArray(in);
break;
case HeapTag.ROOT_UNKNOWN:
roots.add(readInt(in));
break;
case HeapTag.ROOT_JNI_GLOBAL:
roots.add(readInt(in));
in.skip(4);
break;
case HeapTag.ROOT_JNI_LOCAL:
roots.add(readInt(in));
in.skip(8);
break;
case HeapTag.ROOT_JAVA_FRAME:
roots.add(readInt(in));
in.skip(8);
break;
case HeapTag.ROOT_NATIVE_STACK:
roots.add(readInt(in));
in.skip(4);
break;
case HeapTag.ROOT_STICKY_CLASS:
roots.add(readInt(in));
break;
case HeapTag.ROOT_THREAD_BLOCK:
roots.add(readInt(in));
in.skip(4);
break;
case HeapTag.ROOT_MONITOR_USED:
roots.add(readInt(in));
break;
case HeapTag.ROOT_THREAD_OBJECT:
roots.add(readInt(in));
in.skip(8);
break;
case HeapTag.HPROF_ROOT_INTERNED_STRING:
roots.add(readInt(in));
break;
case HeapTag.HPROF_ROOT_FINALIZING:
roots.add(readInt(in));
break;
case HeapTag.HPROF_ROOT_DEBUGGER:
roots.add(readInt(in));
break;
case HeapTag.HPROF_ROOT_REFERENCE_CLEANUP:
roots.add(readInt(in));
break;
case HeapTag.HPROF_ROOT_VM_INTERNAL:
roots.add(readInt(in));
break;
case HeapTag.HPROF_ROOT_JNI_MONITOR:
roots.add(readInt(in));
in.skip(8);
break;
default :
super.onHeapRecord(tag,reader);
}
}

Fixed version (ground truth):
@Override public void onHeapRecord(int tag,HeapDumpReader reader) throws IOException {
  InputStream in=reader.getInputStream();
switch (tag) {
case HeapTag.INSTANCE_DUMP:
    Instance instance=reader.readInstanceDump();
  writer.writeInstanceDump(instance);
break;
case HeapTag.OBJECT_ARRAY_DUMP:
readObjectArray(in);
break;
case HeapTag.PRIMITIVE_ARRAY_DUMP:
readPrimitiveArray(in);
break;
case HeapTag.ROOT_UNKNOWN:
roots.add(readInt(in));
break;
case HeapTag.ROOT_JNI_GLOBAL:
roots.add(readInt(in));
skip(in,4);
break;
case HeapTag.ROOT_JNI_LOCAL:
roots.add(readInt(in));
skip(in,8);
break;
case HeapTag.ROOT_JAVA_FRAME:
roots.add(readInt(in));
skip(in,8);
break;
case HeapTag.ROOT_NATIVE_STACK:
roots.add(readInt(in));
skip(in,4);
break;
case HeapTag.ROOT_STICKY_CLASS:
roots.add(readInt(in));
break;
case HeapTag.ROOT_THREAD_BLOCK:
roots.add(readInt(in));
skip(in,4);
break;
case HeapTag.ROOT_MONITOR_USED:
roots.add(readInt(in));
break;
case HeapTag.ROOT_THREAD_OBJECT:
roots.add(readInt(in));
skip(in,8);
break;
case HeapTag.HPROF_ROOT_INTERNED_STRING:
roots.add(readInt(in));
break;
case HeapTag.HPROF_ROOT_FINALIZING:
roots.add(readInt(in));
break;
case HeapTag.HPROF_ROOT_DEBUGGER:
roots.add(readInt(in));
break;
case HeapTag.HPROF_ROOT_REFERENCE_CLEANUP:
roots.add(readInt(in));
break;
case HeapTag.HPROF_ROOT_VM_INTERNAL:
roots.add(readInt(in));
break;
case HeapTag.HPROF_ROOT_JNI_MONITOR:
roots.add(readInt(in));
skip(in,8);
break;
default :
super.onHeapRecord(tag,reader);
}
}
Program: 59964
Project: 59964
Buggy source:
/** 
 * Crunch a HPROF file, converting it to BMD format.
 * @param inFile Input file (hprof)
 * @param out    Output (BMD)
 * @throws IOException If an error occurs while writing the output data
 */
public static void crunch(File inFile,OutputStream out) throws IOException {
  CrunchProcessor processor=new CrunchProcessor(out);
  InputStream in=new FileInputStream(inFile);
  HprofReader reader=new HprofReader(in,processor);
  while (reader.hasNext()) {
    reader.next();
  }
  processor.allClassesRead();
  in.close();
  in=new FileInputStream(inFile);
  reader=new HprofReader(in,processor);
  while (reader.hasNext()) {
    reader.next();
  }
  processor.finish();
}

Fixed version (ground truth):
/** 
 * Crunch a HPROF file, converting it to BMD format.
 * @param inFile Input file (hprof)
 * @param out    Output (BMD)
 * @throws IOException If an error occurs while writing the output data
 */
public static void crunch(File inFile,OutputStream out) throws IOException {
  CrunchProcessor processor=new CrunchProcessor(out);
  InputStream in=new BufferedInputStream(new FileInputStream(inFile));
  HprofReader reader=new HprofReader(in,processor);
  while (reader.hasNext()) {
    reader.next();
  }
  processor.allClassesRead();
  in.close();
  in=new BufferedInputStream(new FileInputStream(inFile));
  reader=new HprofReader(in,processor);
  while (reader.hasNext()) {
    reader.next();
  }
  processor.finish();
}
Program: 59965
Project: 59965
Buggy source:
@Override public void onRecord(int tag,int timestamp,int length,HprofReader reader) throws IOException {
  if (tag == Tag.STRING) {
    reader.getInputStream().skip(length);
  }
 else   if (tag == Tag.HEAP_DUMP || tag == Tag.HEAP_DUMP_SEGMENT) {
    if (writeUpdatedClassDefinitions) {
      writeClasses(tag,timestamp);
      writeUpdatedClassDefinitions=false;
    }
    ByteArrayOutputStream buffer=new ByteArrayOutputStream();
    HeapDumpReader heapReader=new HeapDumpReader(reader.getInputStream(),length,new ClassDefinitionRemoverProcessor(buffer));
    while (heapReader.hasNext()) {
      heapReader.next();
    }
    byte[] data=buffer.toByteArray();
    writer.writeRecordHeader(tag,timestamp,data.length);
    out.write(data);
  }
 else {
    super.onRecord(tag,timestamp,length,reader);
  }
}

Fixed version (ground truth):
@Override public void onRecord(int tag,int timestamp,int length,HprofReader reader) throws IOException {
  if (tag == Tag.STRING) {
    skip(reader.getInputStream(),length);
  }
 else   if (tag == Tag.HEAP_DUMP || tag == Tag.HEAP_DUMP_SEGMENT) {
    if (writeUpdatedClassDefinitions) {
      writeClasses(tag,timestamp);
      writeUpdatedClassDefinitions=false;
    }
    ByteArrayOutputStream buffer=new ByteArrayOutputStream();
    HeapDumpReader heapReader=new HeapDumpReader(reader.getInputStream(),length,new ClassDefinitionRemoverProcessor(buffer));
    while (heapReader.hasNext()) {
      heapReader.next();
    }
    byte[] data=buffer.toByteArray();
    writer.writeRecordHeader(tag,timestamp,data.length);
    out.write(data);
  }
 else {
    super.onRecord(tag,timestamp,length,reader);
  }
}
Program: 59968
Project: 59968
Buggy source:
@Override public void onRecord(int tag,int timestamp,int length,HprofReader reader) throws IOException {
  reader.getInputStream().skip(length);
}

Fixed version (ground truth):
@Override public void onRecord(int tag,int timestamp,int length,HprofReader reader) throws IOException {
  skip(reader.getInputStream(),length);
}
Program: 59969
Project: 59969
Buggy source:
@Override public void run(C configuration,Environment environment) throws Exception {
  pool=getJedisFactory(configuration).build(environment);
  environment.healthChecks().register("String_Node_Str",new JedisHealthCheck(pool));
  environment.jersey().register(new JedisFactory(pool));
}

Fixed version (ground truth):
@Override public void run(C configuration,Environment environment) throws Exception {
  pool=getJedisFactory(configuration).build(environment);
  environment.healthChecks().register("String_Node_Str",new JedisHealthCheck(pool));
  environment.jersey().register(new JedisPoolBinder(pool));
}
Program: 59970
Project: 59970
Buggy source:
public static long getRandomLong(long val,Random rand){
  if (val == 0) {
    return 0;
  }
  int low=(int)(val & Integer.MIN_VALUE);
  int mid=(int)((val >>> 31) & Integer.MIN_VALUE);
  int high=(int)((val >>> 62) & Integer.MIN_VALUE);
  boolean mh=(mid | high) > 0;
  long r=mh ? rand.nextInt() & Integer.MAX_VALUE : rand.nextInt(low);
  if (mh)   r|=(high > 0 ? rand.nextInt() & Integer.MAX_VALUE : rand.nextInt(mid)) << 31;
  if (high > 0)   r|=rand.nextInt(high) << 62;
  return r;
}

Fixed version (ground truth):
public static long getRandomLong(long val,Random rand){
  if (val == 0) {
    return 0;
  }
  int low=(int)(val & Integer.MAX_VALUE);
  int mid=(int)((val >>> 31) & Integer.MAX_VALUE);
  int high=(int)((val >>> 62) & Integer.MAX_VALUE);
  boolean mh=(mid | high) > 0;
  long r=mh ? rand.nextInt() & Integer.MAX_VALUE : rand.nextInt(low);
  if (mh)   r|=(high > 0 ? rand.nextInt() & Integer.MAX_VALUE : rand.nextInt(mid)) << 31;
  if (high > 0)   r|=rand.nextInt(high) << 62;
  return r;
}
Program: 59971
Project: 59971
Buggy source:
@Override public ItemStack transferStackInSlot(EntityPlayer player,int slotIndex){
  ItemStack stack=null;
  Slot slot=(Slot)inventorySlots.get(slotIndex);
  int invPlayer=27;
  int invFull=invPlayer + 9;
  int invTile=invFull + getSizeInventory();
  if (slot != null && slot.getHasStack()) {
    ItemStack stackInSlot=slot.getStack();
    stack=stackInSlot.copy();
    if (slotIndex < invFull) {
      if (!mergeItemStack(stackInSlot,invFull,invTile,false)) {
        return null;
      }
    }
 else     if (!mergeItemStack(stackInSlot,0,invFull,true)) {
      return null;
    }
    if (stackInSlot.stackSize <= 0) {
      slot.putStack((ItemStack)null);
    }
 else {
      slot.putStack(stackInSlot);
      slot.onSlotChanged();
    }
    if (stackInSlot.stackSize >= stack.stackSize) {
      return null;
    }
  }
  return stack;
}

Fixed version (ground truth):
@Override public ItemStack transferStackInSlot(EntityPlayer player,int slotIndex){
  ItemStack stack=null;
  Slot slot=(Slot)inventorySlots.get(slotIndex);
  int invPlayer=27;
  int invFull=invPlayer + 9;
  int invTile=invFull + getSizeInventory();
  if (slot != null && slot.getHasStack()) {
    ItemStack stackInSlot=slot.getStack();
    stack=stackInSlot.copy();
    if (slotIndex < invFull) {
      if (!mergeItemStack(stackInSlot,invFull,invTile,false)) {
        return null;
      }
    }
 else     if (!mergeItemStack(stackInSlot,0,invFull,true)) {
      return null;
    }
    if (stackInSlot.stackSize <= 0) {
      slot.putStack((ItemStack)null);
    }
 else {
      slot.putStack(stackInSlot);
      slot.onSlotChanged();
    }
    if (stackInSlot.stackSize == stack.stackSize) {
      return null;
    }
    slot.onPickupFromSlot(player,stackInSlot);
  }
  return stack;
}
Program: 59972
Project: 59972
Buggy source:
public IEnderDestination getOutput(boolean onlyLoaded){
  if (output == null || output.isNotValid()) {
    output=null;
    if (!DimensionManager.isDimensionRegistered(dimension)) {
      return null;
    }
    WorldServer world=DimensionManager.getWorld(dimension);
    if (world == null && !onlyLoaded) {
      DimensionManager.initDimension(dimension);
      world=DimensionManager.getWorld(dimension);
    }
 else {
      return null;
    }
    if (!onlyLoaded || world.blockExists(x,y,z)) {
      TileEntity te=world.getTileEntity(x,y,z);
      if (te instanceof IEnderDestination) {
        output=(IEnderDestination)te;
      }
 else {
        isInvalid=true;
      }
    }
  }
  return output;
}

Fixed version (ground truth):
public IEnderDestination getOutput(boolean onlyLoaded){
  if (output == null || output.isNotValid()) {
    output=null;
    if (!DimensionManager.isDimensionRegistered(dimension)) {
      return null;
    }
    WorldServer world=DimensionManager.getWorld(dimension);
    if (world == null && !onlyLoaded) {
      DimensionManager.initDimension(dimension);
      world=DimensionManager.getWorld(dimension);
    }
 else {
      return null;
    }
    if (world.blockExists(x,y,z)) {
      TileEntity te=world.getTileEntity(x,y,z);
      if (te instanceof IEnderDestination) {
        output=(IEnderDestination)te;
      }
 else {
        isInvalid=true;
      }
    }
  }
  return output;
}
Program: 59973
Project: 59973
Buggy source:
protected void rehashIfNecessary(){
  Entry[] old=hashTable, newTable;
  if (size > old.length * 2 && old.length < Ints.MAX_POWER_OF_TWO) {
synchronized (hashTable) {
      int newTableSize=old.length * 2, newMask=newTableSize - 1;
      newTable=hashTable=new Entry[newTableSize];
      mask=newMask;
      for (int bucket=old.length; bucket-- > 0; ) {
        Entry entry=old[bucket];
        while (entry != null) {
          Entry nextEntry=entry.nextInBucket;
          int keyBucket=entry.hash & newMask;
          entry.nextInBucket=newTable[keyBucket];
          newTable[keyBucket]=entry;
          entry=nextEntry;
        }
      }
    }
  }
}

Fixed version (ground truth):
protected void rehashIfNecessary(){
  Entry[] old=hashTable, newTable;
  if (size > old.length * 2 && old.length < Ints.MAX_POWER_OF_TWO) {
synchronized (hashTable) {
      int newTableSize=old.length * 2, newMask=newTableSize - 1;
      newTable=new Entry[newTableSize];
      mask=newMask;
      for (int bucket=old.length; bucket-- > 0; ) {
        Entry entry=old[bucket];
        while (entry != null) {
          Entry nextEntry=entry.nextInBucket;
          int keyBucket=entry.hash & newMask;
          entry.nextInBucket=newTable[keyBucket];
          newTable[keyBucket]=entry;
          entry=nextEntry;
        }
      }
      hashTable=newTable;
    }
  }
}
Program: 59974
Project: 59974
Buggy source:
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
  int expectedModCount=modCount;
  s.defaultWriteObject();
  s.writeInt(size);
  Entry n=head;
  for (int i=0; i < size; i++) {
    s.writeObject(n);
    n=n.next;
  }
  if (modCount != expectedModCount) {
    throw new ConcurrentModificationException();
  }
}

Fixed version (ground truth):
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
  int expectedModCount=modCount;
  s.defaultWriteObject();
  s.writeInt(size);
  Entry n=head;
  for (int i=0; i < size; i++) {
    s.writeObject(n.key);
    n=n.next;
  }
  if (modCount != expectedModCount) {
    throw new ConcurrentModificationException();
  }
}
Program: 59975
Project: 59975
Buggy source:
public static NBTTagCompound setItemStackTagName(NBTTagCompound tag,String name){
  if (name == "String_Node_Str") {
    return null;
  }
  if (tag == null) {
    tag=new NBTTagCompound();
  }
  if (!tag.hasKey("String_Node_Str")) {
    tag.setTag("String_Node_Str",new NBTTagCompound());
  }
  tag.getCompoundTag("String_Node_Str").setString("String_Node_Str",name);
  return tag;
}

Fixed version (ground truth):
public static NBTTagCompound setItemStackTagName(NBTTagCompound tag,String name){
  if (Strings.isNullOrEmpty(name)) {
    return null;
  }
  if (tag == null) {
    tag=new NBTTagCompound();
  }
  if (!tag.hasKey("String_Node_Str")) {
    tag.setTag("String_Node_Str",new NBTTagCompound());
  }
  tag.getCompoundTag("String_Node_Str").setString("String_Node_Str",name);
  return tag;
}
Program: 59976
Project: 59976
Buggy source:
private static void alterDelegate(Object obj,Object repl){
  if (obj instanceof Item) {
    RegistryDelegate<Item> delegate=((Item)obj).delegate;
    ReflectionHelper.setPrivateValue(DelegateClass,delegate,repl,"String_Node_Str");
  }
}

Fixed version (ground truth):
private static void alterDelegate(Object obj,Object repl){
  if (obj instanceof Item) {
    RegistryDelegate<Item> delegate=((Item)obj).delegate;
    ReflectionHelper.setPrivateValue(DelegateClass,delegate,repl,"String_Node_Str");
    ReflectionHelper.setPrivateValue(DelegateClass,((Item)repl).delegate,delegate.name(),"String_Node_Str");
  }
}
Program: 59977
Project: 59977
Buggy source:
public int findFreeFrequency(String channel){
  BitSet set=usedTeleports.get(channel);
  if (set == null) {
    return -1;
  }
  return set.nextClearBit(0);
}

Fixed version (ground truth):
public int findFreeFrequency(String channel){
  BitSet set=usedTeleports.get(channel);
  if (set == null) {
    return 0;
  }
  return set.nextClearBit(0);
}
Program: 59978
Project: 59978
Buggy source:
public IEnderDestination getDestination(IEnderDestination theAttuned){
  TIntObjectHashMap<EnderDestination> map=outputTeleport.get(theAttuned.getChannelString());
  if (map == null) {
    return null;
  }
  EnderDestination dest=map.get(theAttuned.getDestination());
  return dest == null ? null : dest.getOutput();
}

Fixed version (ground truth):
@Override public int getDestination(){
  return -1;
}
Program: 59979
Project: 59979
Buggy source:
public void removeDestination(IEnderDestination theAttuned){
  String channel=theAttuned.getChannelString();
  TIntObjectHashMap<EnderDestination> map=outputTeleport.get(channel);
  if (map == null) {
    return;
  }
  EnderDestination dest=map.get(theAttuned.getFrequency());
  if (dest == null) {
    return;
  }
  if (dest.dimension == theAttuned.dimension()) {
    if (dest.x == theAttuned.x() && dest.y == theAttuned.x() && dest.z == theAttuned.x()) {
      int freq=theAttuned.getFrequency();
      map.remove(freq);
      linkConf.getCategory(channel).remove(String.valueOf(freq));
    }
  }
}

Fixed version (ground truth):
public void removeDestination(IEnderDestination theAttuned){
  String channel=theAttuned.getChannelString();
  TIntObjectHashMap<EnderDestination> map=outputTeleport.get(channel);
  if (map == null) {
    return;
  }
  EnderDestination dest=map.get(theAttuned.getFrequency());
  if (dest == null) {
    return;
  }
  if (dest.dimension == theAttuned.dimension()) {
    if (dest.x == theAttuned.x() && dest.y == theAttuned.y() && dest.z == theAttuned.z()) {
      int freq=theAttuned.getFrequency();
      map.remove(freq);
      linkConf.getCategory(channel).remove(String.valueOf(freq));
    }
  }
}
Program: 59980
Project: 59980
Buggy source:
public static UUID getID(EntityPlayer player){
  if (MinecraftServer.getServer() != null) {
    return player.getGameProfile().getId();
  }
  return getClientId(player);
}

Fixed version (ground truth):
public static UUID getID(EntityPlayer player){
  if (MinecraftServer.getServer() != null && MinecraftServer.getServer().isServerRunning()) {
    return player.getGameProfile().getId();
  }
  return getClientId(player);
}
Program: 59981
Project: 59981
Buggy source:
public int getLastScrollPosition(){
  int position=_elements.size() - 1;
  int heightUsed=_elements.get(position).getHeight();
  while (position > 0 && heightUsed < sizeY) {
    position--;
    heightUsed+=_elements.get(position).getHeight();
  }
  return position + 1;
}

Fixed version (ground truth):
public int getLastScrollPosition(){
  int position=_elements.size() - 1;
  if (position < 0)   return 0;
  int heightUsed=_elements.get(position).getHeight();
  while (position > 0 && heightUsed < sizeY) {
    position--;
    heightUsed+=_elements.get(position).getHeight();
  }
  return position + 1;
}
Program: 59982
Project: 59982
Buggy source:
public static void writeVarInt(int in,ByteBuf out){
  while ((in & ~0x7F) != 0) {
    out.writeByte(in & 127 | 128);
    in>>>=7;
  }
}

Fixed version (ground truth):
public static void writeVarInt(int in,ByteBuf out){
  if (in == 0) {
    out.writeByte(0);
  }
  while (in != 0) {
    out.writeByte(in & 127 | ((in & ~0x7F) != 0 ? 128 : 0));
    in>>>=7;
  }
}
Program: 59983
Project: 59983
Buggy source:
public void remove(IListBoxElement element){
  _elements.remove(element);
}

Fixed version (ground truth):
public void remove(IListBoxElement element){
  int e=_elements.indexOf(element);
  if (_elements.remove(element)) {
    if (e < _firstIndexDisplayed) {
      --_firstIndexDisplayed;
    }
    if (e < _selectedIndex) {
      --_selectedIndex;
    }
  }
}
Program: 59984
Project: 59984
Buggy source:
public IListBoxElement getSelectedElement(){
  if (_selectedIndex == -1 || _selectedIndex == _elements.size()) {
    return null;
  }
  return _elements.get(_selectedIndex);
}

Fixed version (ground truth):
public IListBoxElement getSelectedElement(){
  if (_selectedIndex == -1 || _selectedIndex >= _elements.size()) {
    return null;
  }
  return _elements.get(_selectedIndex);
}
Program: 59985
Project: 59985
Buggy source:
public void removeAt(int index){
  _elements.remove(index);
}

Fixed version (ground truth):
public void removeAt(int index){
  _firstIndexDisplayed=scrollHoriz=0;
  _selectedIndex=-1;
  _elements.remove(index);
}
Program: 59986
Project: 59986
Buggy source:
public static ItemStack simulateAddToOccupiedInventorySlot(IInventory inventory,int slot,ItemStack stack,ItemStack existingStack){
  int stackLimit=Math.min(inventory.getInventoryStackLimit(),stack.getMaxStackSize());
  if (stack.stackSize + existingStack.stackSize > stackLimit) {
    stack.stackSize-=stackLimit - existingStack.stackSize;
    return stack;
  }
  return stackLimit >= stack.stackSize ? null : stack.splitStack(stack.stackSize - stackLimit);
}

Fixed version (ground truth):
public static ItemStack simulateAddToOccupiedInventorySlot(IInventory inventory,int slot,ItemStack stack,ItemStack existingStack){
  int stackLimit=Math.min(inventory.getInventoryStackLimit(),stack.getMaxStackSize());
  if (stack.stackSize + existingStack.stackSize > stackLimit && stackLimit > existingStack.stackSize) {
    stack.stackSize-=stackLimit - existingStack.stackSize;
    return stack;
  }
  return stackLimit >= stack.stackSize ? null : stack.splitStack(stack.stackSize - stackLimit);
}
Program: 59987
Project: 59987
Buggy source:
public static ItemStack addToOccupiedInventorySlot(IInventory inventory,int slot,ItemStack stack,ItemStack existingStack){
  int stackLimit=Math.min(inventory.getInventoryStackLimit(),stack.getMaxStackSize());
  if (stack.stackSize + existingStack.stackSize > stackLimit) {
    int stackDiff=stackLimit - existingStack.stackSize;
    existingStack.stackSize=stackLimit;
    stack.stackSize-=stackDiff;
    inventory.setInventorySlotContents(slot,existingStack);
    return stack;
  }
  existingStack.stackSize+=Math.min(stack.stackSize,stackLimit);
  inventory.setInventorySlotContents(slot,existingStack);
  return stackLimit >= stack.stackSize ? null : stack.splitStack(stack.stackSize - stackLimit);
}

Fixed version (ground truth):
public static ItemStack addToOccupiedInventorySlot(IInventory inventory,int slot,ItemStack stack,ItemStack existingStack){
  int stackLimit=Math.min(inventory.getInventoryStackLimit(),stack.getMaxStackSize());
  if (stack.stackSize + existingStack.stackSize > stackLimit && stackLimit > existingStack.stackSize) {
    int stackDiff=stackLimit - existingStack.stackSize;
    existingStack.stackSize=stackLimit;
    stack.stackSize-=stackDiff;
    inventory.setInventorySlotContents(slot,existingStack);
    return stack;
  }
  existingStack.stackSize+=Math.min(stack.stackSize,stackLimit);
  inventory.setInventorySlotContents(slot,existingStack);
  return stackLimit >= stack.stackSize ? null : stack.splitStack(stack.stackSize - stackLimit);
}
Program: 59988
Project: 59988
Buggy source:
boolean canPlayerAccess(String name);

Fixed version (ground truth):
boolean canPlayerAccess(EntityPlayer player);
Program: 59989
Project: 59989
Buggy source:
public static boolean itemsEqualWithMetadata(ItemStack stackA,ItemStack stackB,boolean checkNBT){
  if (stackA == stackB) {
    return true;
  }
  return itemsEqualWithoutMetadataNoCheck(stackA,stackB) && (!checkNBT || doNBTsMatch(stackA.stackTagCompound,stackB.stackTagCompound));
}

Fixed version (ground truth):
public static boolean itemsEqualWithMetadata(ItemStack stackA,ItemStack stackB,boolean checkNBT){
  return itemsEqualWithMetadata(stackA,stackB) && (!checkNBT || doNBTsMatch(stackA.stackTagCompound,stackB.stackTagCompound));
}
Program: 59990
Project: 59990
Buggy source:
public static boolean itemsIdentical(ItemStack stackA,ItemStack stackB){
  if (stackA == stackB) {
    return true;
  }
  return itemsEqualWithoutMetadataNoCheck(stackA,stackB) && (stackA.getItemDamage() == stackB.getItemDamage()) && doNBTsMatch(stackA.stackTagCompound,stackB.stackTagCompound);
}

Fixed version (ground truth):
public static boolean itemsIdentical(ItemStack stackA,ItemStack stackB){
  return itemsEqualWithoutMetadata(stackA,stackB) && (stackA.getItemDamage() == stackB.getItemDamage()) && doNBTsMatch(stackA.stackTagCompound,stackB.stackTagCompound);
}
Program: 59991
Project: 59991
Buggy source:
public static boolean areItemsEqual(Item itemA,Item itemB){
  if (itemA == itemB) {
    return true;
  }
  if (itemA == null | itemB == null) {
    return false;
  }
  return itemA.equals(itemB);
}

Fixed version (ground truth):
public static boolean areItemsEqual(Item itemA,Item itemB){
  if (itemA == null | itemB == null) {
    return false;
  }
  return itemA == itemB || itemA.equals(itemB);
}
Program: 59992
Project: 59992
Buggy source:
public static boolean itemsEqualForCrafting(ItemStack stackA,ItemStack stackB){
  if (stackA == stackB) {
    return true;
  }
  return itemsEqualWithoutMetadataNoCheck(stackA,stackB) && (!stackA.getHasSubtypes() || ((stackA.getItemDamage() == OreDictionary.WILDCARD_VALUE || stackB.getItemDamage() == OreDictionary.WILDCARD_VALUE) || stackB.getItemDamage() == stackA.getItemDamage()));
}

Fixed version (ground truth):
public static boolean itemsEqualForCrafting(ItemStack stackA,ItemStack stackB){
  return itemsEqualWithoutMetadata(stackA,stackB) && (!stackA.getHasSubtypes() || ((stackA.getItemDamage() == OreDictionary.WILDCARD_VALUE || stackB.getItemDamage() == OreDictionary.WILDCARD_VALUE) || stackB.getItemDamage() == stackA.getItemDamage()));
}
Program: 59993
Project: 59993
Buggy source:
public static boolean doNBTsMatch(NBTTagCompound nbtA,NBTTagCompound nbtB){
  if (nbtA == nbtB) {
    return true;
  }
  if (nbtA != null & nbtB != null) {
    return nbtA.equals(nbtB);
  }
  return false;
}

Fixed version (ground truth):
public static boolean doNBTsMatch(NBTTagCompound nbtA,NBTTagCompound nbtB){
  if (nbtA != null & nbtB != null) {
    return nbtA.equals(nbtB);
  }
  return false;
}
Program: 59994
Project: 59994
Buggy source:
public static boolean itemsEqualWithoutMetadata(ItemStack stackA,ItemStack stackB,boolean checkNBT){
  if (stackA == stackB) {
    return true;
  }
  return itemsEqualWithoutMetadataNoCheck(stackA,stackB) && (!checkNBT || doNBTsMatch(stackA.stackTagCompound,stackB.stackTagCompound));
}

Fixed version (ground truth):
public static boolean itemsEqualWithoutMetadata(ItemStack stackA,ItemStack stackB,boolean checkNBT){
  return itemsEqualWithoutMetadata(stackA,stackB) && (!checkNBT || doNBTsMatch(stackA.stackTagCompound,stackB.stackTagCompound));
}
Program: 59995
Project: 59995
Buggy source:
public void onSlotChanged(){
  player.inventory.mainInventory[containerIndex]=containerWrapper.getContainerStack();
}

Fixed version (ground truth):
public void onSlotChanged(){
  ItemStack item=player.inventory.mainInventory[containerIndex];
  if (valid && (item == null || item.getItem() != containerWrapper.getContainerStack().getItem())) {
    player.inventory.mainInventory[containerIndex]=containerWrapper.getContainerStack();
  }
}
Program: 59996
Project: 59996
Buggy source:
public ContainerInventoryItem(ItemStack stack,InventoryPlayer inventory){
  containerWrapper=new InventoryContainerItemWrapper(this,stack);
  player=inventory.player;
  containerIndex=inventory.currentItem;
}

Fixed version (ground truth):
public ContainerInventoryItem(ItemStack stack,InventoryPlayer inventory){
  player=inventory.player;
  containerIndex=inventory.currentItem;
  containerWrapper=new InventoryContainerItemWrapper(this,stack);
}
Program: 59997
Project: 59997
Buggy source:
@Override public boolean canInteractWith(EntityPlayer player){
  return true;
}

Fixed version (ground truth):
@Override public boolean canInteractWith(EntityPlayer player){
  boolean e=containerWrapper.getDirty();
  if (!valid) {
    if (e) {
      player.inventory.setItemStack(null);
    }
    return false;
  }
  return true;
}
Program: 59998
Project: 59998
Buggy source:
@Override public void markDirty(){
  container.onSlotChanged();
}

Fixed version (ground truth):
@Override public void markDirty(){
  dirty=true;
  container.onSlotChanged();
}
Program: 59999
Project: 59999
Buggy source:
public SliderVertical(GuiBase containerScreen,int x,int y,int width,int height,int maxValue,int minValue){
  super(containerScreen,x,y,width,height,maxValue,minValue);
  int dist=maxValue - minValue;
  setSliderSize(width,dist <= 0 ? height : Math.max(height / dist,9));
}

Fixed version (ground truth):
public SliderVertical(GuiBase containerScreen,int x,int y,int width,int height,int maxValue,int minValue){
  super(containerScreen,x,y,width,height,maxValue,minValue);
  int dist=maxValue - minValue;
  setSliderSize(width,dist <= 0 ? height : Math.max(height / ++dist,9));
}
Program: 60000
Project: 60000
Buggy source:
public void onSlotChanged(){
  ItemStack item=player.inventory.mainInventory[containerIndex];
  if (valid && (item == null || item.getItem() != containerWrapper.getContainerStack().getItem())) {
    player.inventory.mainInventory[containerIndex]=containerWrapper.getContainerStack();
  }
}

Fixed version (ground truth):
public void onSlotChanged(){
  ItemStack item=player.inventory.mainInventory[containerIndex];
  if (valid && item != null && item.getItem() == containerWrapper.getContainerStack().getItem()) {
    player.inventory.mainInventory[containerIndex]=containerWrapper.getContainerStack();
  }
}
Program: 60003
Project: 60003
Buggy source:
protected Entry index(int index){
  Entry x;
  if (index < (size >> 1)) {
    x=head;
    for (int i=index; i-- > 0; )     x=x.next;
  }
 else {
    x=tail;
    for (int i=size; i-- > index; )     x=x.prev;
  }
  return x;
}

Fixed version (ground truth):
protected Entry index(int index){
  Entry x;
  if (index < (size >> 1)) {
    x=head;
    for (int i=index; i-- > 0; )     x=x.next;
  }
 else {
    x=tail;
    for (int i=size - 1; i-- > index; )     x=x.prev;
  }
  return x;
}
Program: 60005
Project: 60005
Buggy source:
public boolean isEqual(ItemWrapper other){
  if (other == null) {
    return false;
  }
  if (metadata == other.metadata) {
    if (item == other.item) {
      return true;
    }
    if (item != null && other.item != null) {
      return item.delegate.get() == item.delegate.get();
    }
  }
  return false;
}

Fixed version (ground truth):
public boolean isEqual(ItemWrapper other){
  if (other == null) {
    return false;
  }
  if (metadata == other.metadata) {
    if (item == other.item) {
      return true;
    }
    if (item != null && other.item != null) {
      return item.delegate.get() == other.item.delegate.get();
    }
  }
  return false;
}
Program: 60008
Project: 60008
Buggy source:
@Override public void set(E e){
  if (lastReturned == null)   throw new IllegalStateException();
  checkForComodification();
  linkBefore(e,lastReturned);
  delete(lastReturned);
  expectedModCount+=2;
}

Fixed version (ground truth):
@Override public void set(E e){
  checkForComodification();
  if (lastReturned == null)   throw new IllegalStateException();
  linkBefore(e,lastReturned);
  unlink(lastReturned);
  lastReturned=(next == null) ? tail : next.prev;
  expectedModCount+=2;
}
Program: 60009
Project: 60009
Buggy source:
public static void clearClientNames(){
  clientFrequencyNames=new LinkedHashMap<String,String>();
  clientFrequencyNamesReversed=new LinkedHashMap<String,String>();
}

Fixed version (ground truth):
public static void clearClientNames(){
  clientFrequencyNames.clear();
  clientFrequencyNamesReversed.clear();
}
Program: 60010
Project: 60010
Buggy source:
@Override public void handleMouseInput(){
  mouseX=Mouse.getEventX() * width / mc.displayWidth - guiLeft;
  mouseY=height - Mouse.getEventY() * height / mc.displayHeight - 1 - guiTop;
  int wheelMovement=Mouse.getEventDWheel();
  if (wheelMovement != 0) {
    for (int i=elements.size(); i-- > 0; ) {
      ElementBase c=elements.get(i);
      if (!c.isVisible() || !c.isEnabled() || !c.intersectsWith(mouseX,mouseY)) {
        continue;
      }
      if (c.onMouseWheel(mouseX,mouseY,wheelMovement)) {
        return;
      }
    }
  }
  super.handleMouseInput();
}

Fixed version (ground truth):
@Override public void handleMouseInput(){
  int x=Mouse.getEventX() * width / mc.displayWidth - guiLeft;
  int y=height - Mouse.getEventY() * height / mc.displayHeight - 1 - guiTop;
  mouseX=x - guiLeft;
  mouseY=y - guiTop;
  int wheelMovement=Mouse.getEventDWheel();
  if (wheelMovement != 0) {
    for (int i=elements.size(); i-- > 0; ) {
      ElementBase c=elements.get(i);
      if (!c.isVisible() || !c.isEnabled() || !c.intersectsWith(mouseX,mouseY)) {
        continue;
      }
      if (c.onMouseWheel(mouseX,mouseY,wheelMovement)) {
        return;
      }
    }
  }
  super.handleMouseInput();
}
Program: 60011
Project: 60011
Buggy source:
public void drawTooltip(List<String> list){
  drawTooltipHoveringText(list,mouseX,mouseY,fontRendererObj);
  tooltip.clear();
}

Fixed version (ground truth):
public void drawTooltip(List<String> list){
  drawTooltipHoveringText(list,mouseX + guiLeft,mouseY + guiTop,fontRendererObj);
  tooltip.clear();
}
Program: 60012
Project: 60012
Buggy source:
protected void updateElements(){
  for (int i=elements.size(); i-- > 0; ) {
    ElementBase c=elements.get(i);
    if (c.isVisible() && c.isEnabled()) {
      c.update(mouseX,mouseY);
    }
  }
}

Fixed version (ground truth):
protected final void updateElements(){
  for (int i=elements.size(); i-- > 0; ) {
    ElementBase c=elements.get(i);
    if (c.isVisible() && c.isEnabled()) {
      c.update(mouseX,mouseY);
    }
  }
}
Program: 60014
Project: 60014
Buggy source:
/** 
 * Draws the tabs for this GUI. Handles Tab open/close animation.
 */
protected void drawTabs(float partialTick,boolean foreground){
  if (foreground) {
    return;
  }
  int yPosRight=4;
  int yPosLeft=4;
  for (int i=tabs.size(); i-- > 0; ) {
    TabBase tab=tabs.get(i);
    tab.update();
    if (!tab.isVisible()) {
      continue;
    }
    if (tab.side == 0) {
      tab.draw(guiLeft,guiTop + yPosLeft);
      yPosLeft+=tab.currentHeight;
    }
 else {
      tab.draw(guiLeft + xSize,guiTop + yPosRight);
      yPosRight+=tab.currentHeight;
    }
  }
}

Fixed version (ground truth):
/** 
 * Draws the tabs for this GUI. Handles Tab open/close animation.
 */
protected void drawTabs(float partialTick,boolean foreground){
  if (foreground) {
    return;
  }
  int yPosRight=4;
  int yPosLeft=4;
  for (int i=0; i < tabs.size(); i++) {
    TabBase tab=tabs.get(i);
    tab.update();
    if (!tab.isVisible()) {
      continue;
    }
    if (tab.side == 0) {
      tab.draw(guiLeft,guiTop + yPosLeft);
      yPosLeft+=tab.currentHeight;
    }
 else {
      tab.draw(guiLeft + xSize,guiTop + yPosRight);
      yPosRight+=tab.currentHeight;
    }
  }
}
Program: 60015
Project: 60015
Buggy source:
protected TabBase getTabAtPosition(int mX,int mY){
  int xShift=0;
  int yShift=4;
  for (int i=tabs.size(); i-- > 0; ) {
    TabBase tab=tabs.get(i);
    if (!tab.isVisible() || tab.side == 1) {
      continue;
    }
    tab.currentShiftX=xShift;
    tab.currentShiftY=yShift;
    if (tab.intersectsWith(mX,mY,xShift,yShift)) {
      return tab;
    }
    yShift+=tab.currentHeight;
  }
  xShift=xSize;
  yShift=4;
  for (int i=tabs.size(); i-- > 0; ) {
    TabBase tab=tabs.get(i);
    if (!tab.isVisible() || tab.side == 0) {
      continue;
    }
    tab.currentShiftX=xShift;
    tab.currentShiftY=yShift;
    if (tab.intersectsWith(mX,mY,xShift,yShift)) {
      return tab;
    }
    yShift+=tab.currentHeight;
  }
  return null;
}

Fixed version (ground truth):
protected TabBase getTabAtPosition(int mX,int mY){
  int xShift=0;
  int yShift=4;
  for (int i=0; i < tabs.size(); i++) {
    TabBase tab=tabs.get(i);
    if (!tab.isVisible() || tab.side == 1) {
      continue;
    }
    tab.currentShiftX=xShift;
    tab.currentShiftY=yShift;
    if (tab.intersectsWith(mX,mY,xShift,yShift)) {
      return tab;
    }
    yShift+=tab.currentHeight;
  }
  xShift=xSize;
  yShift=4;
  for (int i=0; i < tabs.size(); i++) {
    TabBase tab=tabs.get(i);
    if (!tab.isVisible() || tab.side == 0) {
      continue;
    }
    tab.currentShiftX=xShift;
    tab.currentShiftY=yShift;
    if (tab.intersectsWith(mX,mY,xShift,yShift)) {
      return tab;
    }
    yShift+=tab.currentHeight;
  }
  return null;
}
Program: 60016
Project: 60016
Buggy source:
@Override public void handleMouseInput(){
  int x=Mouse.getEventX() * width / mc.displayWidth - guiLeft;
  int y=height - Mouse.getEventY() * height / mc.displayHeight - 1 - guiTop;
  mouseX=x - guiLeft;
  mouseY=y - guiTop;
  int wheelMovement=Mouse.getEventDWheel();
  if (wheelMovement != 0) {
    for (int i=elements.size(); i-- > 0; ) {
      ElementBase c=elements.get(i);
      if (!c.isVisible() || !c.isEnabled() || !c.intersectsWith(mouseX,mouseY)) {
        continue;
      }
      if (c.onMouseWheel(mouseX,mouseY,wheelMovement)) {
        return;
      }
    }
  }
  super.handleMouseInput();
}

Fixed version (ground truth):
@Override public void handleMouseInput(){
  int x=Mouse.getEventX() * width / mc.displayWidth;
  int y=height - Mouse.getEventY() * height / mc.displayHeight - 1;
  mouseX=x - guiLeft;
  mouseY=y - guiTop;
  int wheelMovement=Mouse.getEventDWheel();
  if (wheelMovement != 0) {
    for (int i=elements.size(); i-- > 0; ) {
      ElementBase c=elements.get(i);
      if (!c.isVisible() || !c.isEnabled() || !c.intersectsWith(mouseX,mouseY)) {
        continue;
      }
      if (c.onMouseWheel(mouseX,mouseY,wheelMovement)) {
        return;
      }
    }
  }
  super.handleMouseInput();
}
Program: 60017
Project: 60017
Buggy source:
/** 
 * Draws the elements for this GUI.
 */
protected void drawElements(float partialTick,boolean foreground){
  if (foreground) {
    for (int i=elements.size(); i-- > 0; ) {
      ElementBase element=elements.get(i);
      if (element.isVisible()) {
        element.drawForeground(mouseX,mouseY);
      }
    }
  }
 else {
    for (int i=elements.size(); i-- > 0; ) {
      ElementBase element=elements.get(i);
      if (element.isVisible()) {
        element.drawBackground(mouseX,mouseY,partialTick);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Draws the elements for this GUI.
 */
protected void drawElements(float partialTick,boolean foreground){
  if (foreground) {
    for (int i=0; i < elements.size(); i++) {
      ElementBase element=elements.get(i);
      if (element.isVisible()) {
        element.drawForeground(mouseX,mouseY);
      }
    }
  }
 else {
    for (int i=0; i < elements.size(); i++) {
      ElementBase element=elements.get(i);
      if (element.isVisible()) {
        element.drawBackground(mouseX,mouseY,partialTick);
      }
    }
  }
}
Program: 60018
Project: 60018
Buggy source:
public BlockWrapper(Block block,int metadata){
  this.block=block;
  this.metadata=metadata;
  this.hashcode=block.hashCode() * 31 + metadata;
}

Fixed version (ground truth):
public BlockWrapper(Block block,int metadata){
  this.block=block;
  this.metadata=metadata;
}
Program: 60019
Project: 60019
Buggy source:
public static int getHashCode(Block block,int metadata){
  return block.hashCode() * 31 + metadata;
}

Fixed version (ground truth):
public static int getHashCode(Block block,int metadata){
  return metadata | Block.getIdFromBlock(block) << 16;
}
Program: 60020
Project: 60020
Buggy source:
@Override public int hashCode(){
  return hashcode;
}

Fixed version (ground truth):
@Override public int hashCode(){
  return metadata | Block.getIdFromBlock(block) << 16;
}
Program: 60021
Project: 60021
Buggy source:
private void removeFromParent(View view){
  ViewGroup parent=(ViewGroup)view.getParent();
  parent.removeView(view);
}

Fixed version (ground truth):
private void removeFromParent(final View view){
  final ViewGroup parent=(ViewGroup)view.getParent();
  parent.post(new Runnable(){
    @Override public void run(){
      parent.removeView(view);
    }
  }
);
}