nus-yam/ex-repair huggingface dataset:
Program: 26490
Project: 26490
Buggy source:
private void updateChart(){
  recalculateGapThreshold(chart,0);
  if (hasSecondaryYAxis) {
    recalculateGapThreshold(chart,1);
  }
  chart.getXYPlot().getRangeAxis(0).configure();
  if (chart.getLegend() != null) {
    int seriesCount=chart.getXYPlot().getDataset(0).getSeriesCount();
    if (hasSecondaryYAxis) {
      seriesCount+=chart.getXYPlot().getDataset(1).getSeriesCount();
      NumberAxis a=(NumberAxis)chart.getXYPlot().getRangeAxis(1);
      a.configure();
    }
    if (seriesCount > 1) {
      addLegend();
    }
  }
}

Fixed version (ground truth):
private void updateChart(){
  recalculateGapThreshold(0);
  if (hasSecondaryYAxis) {
    recalculateGapThreshold(1);
  }
  chart.getXYPlot().getRangeAxis(0).configure();
  if (chart.getLegend() == null) {
    int seriesCount=chart.getXYPlot().getDataset(0).getSeriesCount();
    if (hasSecondaryYAxis) {
      seriesCount+=chart.getXYPlot().getDataset(1).getSeriesCount();
      NumberAxis a=(NumberAxis)chart.getXYPlot().getRangeAxis(1);
      a.configure();
    }
    if (seriesCount > 1) {
      addLegend();
    }
  }
}
Program: 26491
Project: 26491
Buggy source:
public void initChart(LineChartDefinition definition){
  stacked=definition.isStacked();
  hasSecondaryYAxis=definition.hasSecondaryYAxis();
  initChart();
  chart.setTitle(definition.getTitle());
  chart.getXYPlot().getRangeAxis().setLabel(definition.getYAxisLabel());
  if (hasSecondaryYAxis) {
    chart.getXYPlot().getRangeAxis(1).setLabel(definition.getSecondaryYAxisLabel());
  }
  if ("String_Node_Str".equals(definition.getXAxisLabel())) {
    chart.getXYPlot().getDomainAxis().setLabel("String_Node_Str");
  }
 else {
    chart.getXYPlot().getDomainAxis().setLabel(definition.getXAxisLabel());
  }
  if (definition.usePercentYAxis()) {
    LineChartBuilder.setPercentYAxis(chart);
  }
}

Fixed version (ground truth):
public void initChart(LineChartDefinition definition){
  stacked=definition.isStacked();
  hasSecondaryYAxis=definition.hasSecondaryYAxis();
  initChart();
  chart.setTitle(definition.getTitle());
  XYPlot plot=chart.getXYPlot();
  plot.getRangeAxis().setLabel(definition.getYAxisLabel());
  if (hasSecondaryYAxis) {
    plot.getRangeAxis(1).setLabel(definition.getSecondaryYAxisLabel());
  }
  if ("String_Node_Str".equals(definition.getXAxisLabel())) {
    plot.getDomainAxis().setLabel("String_Node_Str");
  }
 else {
    plot.getDomainAxis().setLabel(definition.getXAxisLabel());
  }
  if (definition.usePercentYAxis()) {
    LineChartBuilder.setPercentYAxis(chart);
  }
}
Program: 26493
Project: 26493
Buggy source:
@Override public View onCreateInputView(){
  KeyboardView ret=new KeyboardView(this,null);
  ret.setKeyboard(new Keyboard(this,R.xml.keyboarddef));
  ret.setOnKeyboardActionListener(this);
  return ret;
}

Fixed version (ground truth):
@Override public View onCreateInputView(){
  KeyboardView ret=new KeyboardView(this,null);
  ret.setKeyboard(new Keyboard(this,R.xml.keyboarddef));
  ret.setOnKeyboardActionListener(this);
  ret.setPreviewEnabled(false);
  return ret;
}
Program: 26496
Project: 26496
Buggy source:
private void addPlayersToGame(Game game){
  Player p1=new Player();
  p1.setChips(game.getGameStructure().getStartingChips());
  p1.setName("String_Node_Str");
  p1=gameService.addNewPlayerToGame(game,p1);
  assertTrue(p1.getId() > 0);
  Player p2=new Player();
  p2.setChips(game.getGameStructure().getStartingChips());
  p2.setName("String_Node_Str");
  p2=gameService.addNewPlayerToGame(game,p2);
  assertTrue(p2.getId() > 0);
}

Fixed version (ground truth):
private void addPlayersToGame(Game game){
  flushAndClear();
  game=gameService.getGameById(game.getId(),true);
  Player p1=new Player();
  p1.setChips(game.getGameStructure().getStartingChips());
  p1.setName("String_Node_Str");
  p1=gameService.addNewPlayerToGame(game,p1);
  assertTrue(p1.getId() > 0);
  Player p2=new Player();
  p2.setChips(game.getGameStructure().getStartingChips());
  p2.setName("String_Node_Str");
  p2=gameService.addNewPlayerToGame(game,p2);
  assertTrue(p2.getId() > 0);
}
Program: 26497
Project: 26497
Buggy source:
@Test(expected=IllegalStateException.class) public void testCantStartGamePlayers(){
  Game game=gameService.saveGame(createTestGame());
  gameService.addNewPlayerToGame(game,new Player());
  flushAndClear();
  game=gameService.getGameById(game.getId(),true);
  assertNotNull(game.getPlayers());
  gameService.startGame(game);
}

Fixed version (ground truth):
@Test(expected=IllegalStateException.class) public void testCantStartGamePlayers(){
  Game game=gameService.saveGame(createTestGame());
  flushAndClear();
  game=gameService.getGameById(game.getId(),true);
  gameService.addNewPlayerToGame(game,new Player());
  flushAndClear();
  game=gameService.getGameById(game.getId(),true);
  assertNotNull(game.getPlayers());
  gameService.startGame(game);
}
Program: 26499
Project: 26499
Buggy source:
private Game gameSetup(){
  Game game=new Game();
  game.setName("String_Node_Str");
  game.setGameType(GameType.TOURNAMENT);
  GameStructure gs=new GameStructure();
  gs.setBlindLength(10);
  gs.setBlindLevels(CommonTournamentFormats.TWO_HR_NINEPPL.getBlindLevels());
  gs.setStartingChips(1000);
  game.setGameStructure(gs);
  game=gameService.saveGame(game);
  Player p1=new Player();
  p1.setChips(game.getGameStructure().getStartingChips());
  p1.setName("String_Node_Str");
  p1=gameService.addNewPlayerToGame(game,p1);
  Player p2=new Player();
  p2.setChips(game.getGameStructure().getStartingChips());
  p2.setName("String_Node_Str");
  p2=gameService.addNewPlayerToGame(game,p2);
  Player p3=new Player();
  p3.setChips(game.getGameStructure().getStartingChips());
  p3.setName("String_Node_Str");
  p3=gameService.addNewPlayerToGame(game,p3);
  Player p4=new Player();
  p4.setChips(game.getGameStructure().getStartingChips());
  p4.setName("String_Node_Str");
  p4=gameService.addNewPlayerToGame(game,p4);
  flushAndClear();
  game=gameService.getGameById(game.getId(),true);
  return gameService.startGame(game);
}

Fixed version (ground truth):
private Game gameSetup(){
  Game game=new Game();
  game.setName("String_Node_Str");
  game.setGameType(GameType.TOURNAMENT);
  GameStructure gs=new GameStructure();
  gs.setBlindLength(10);
  gs.setBlindLevels(CommonTournamentFormats.TWO_HR_NINEPPL.getBlindLevels());
  gs.setStartingChips(1000);
  game.setGameStructure(gs);
  game=gameService.saveGame(game);
  flushAndClear();
  game=gameService.getGameById(game.getId(),true);
  Player p1=new Player();
  p1.setChips(game.getGameStructure().getStartingChips());
  p1.setName("String_Node_Str");
  p1=gameService.addNewPlayerToGame(game,p1);
  Player p2=new Player();
  p2.setChips(game.getGameStructure().getStartingChips());
  p2.setName("String_Node_Str");
  p2=gameService.addNewPlayerToGame(game,p2);
  Player p3=new Player();
  p3.setChips(game.getGameStructure().getStartingChips());
  p3.setName("String_Node_Str");
  p3=gameService.addNewPlayerToGame(game,p3);
  Player p4=new Player();
  p4.setChips(game.getGameStructure().getStartingChips());
  p4.setName("String_Node_Str");
  p4=gameService.addNewPlayerToGame(game,p4);
  flushAndClear();
  game=gameService.getGameById(game.getId(),true);
  return gameService.startGame(game);
}
Program: 26500
Project: 26500
Buggy source:
@Override @Transactional public void endHand(HandEntity hand){
  hand=handDao.merge(hand);
  Game game=hand.getGame();
  game.setCurrentHand(null);
  List<PlayerHand> players=new ArrayList<PlayerHand>();
  for (  PlayerHand p : hand.getPlayers()) {
    if (p.getPlayer().getChips() != 0) {
      players.add(p);
    }
  }
  game.setPlayersRemaining(players.size());
  Player nextButton=this.getNextPlayerInGameOrder(players,game.getPlayerInBTN());
  game.setPlayerInBTN(nextButton);
  gameDao.merge(game);
  hand.setCards(new ArrayList<Card>());
  handDao.merge(hand);
}

Fixed version (ground truth):
@Override @Transactional public void endHand(HandEntity hand){
  hand=handDao.merge(hand);
  Game game=hand.getGame();
  game.setCurrentHand(null);
  List<PlayerHand> players=new ArrayList<PlayerHand>();
  int count=0;
  for (  PlayerHand p : hand.getPlayers()) {
    if (p.getPlayer().getChips() != 0) {
      players.add(p);
      count++;
    }
 else     if (p.getPlayer().equals(game.getPlayerInBTN())) {
      players.add(p);
    }
  }
  game.setPlayersRemaining(count);
  if (count < 2) {
  }
  Player nextButton=this.getNextPlayerInGameOrder(players,game.getPlayerInBTN());
  game.setPlayerInBTN(nextButton);
  gameDao.merge(game);
  hand.setCards(new ArrayList<Card>());
  handDao.merge(hand);
}
Program: 26501
Project: 26501
Buggy source:
@Test public void testEndHandWithElimination(){
  Game game=setupGame();
  HandEntity hand=handService.startNewHand(game);
  List<PlayerHand> players=new ArrayList<PlayerHand>();
  players.addAll(hand.getPlayers());
  Collections.sort(players);
  assertEquals(handService.getPlayerInBB(hand),players.get(2).getPlayer());
  players.get(2).getPlayer().setChips(0);
  flushAndClear();
  game=gameDao.findById(game.getId());
  handService.endHand(game.getCurrentHand());
  hand=handService.startNewHand(game);
  assertEquals("String_Node_Str",players.size() - 1,hand.getPlayers().size());
  assertEquals(game.getPlayerInBTN(),players.get(1).getPlayer());
  assertEquals(players.get(0).getPlayer(),handService.getPlayerInBB(hand));
  assertEquals(players.get(3).getPlayer(),handService.getPlayerInSB(hand));
}

Fixed version (ground truth):
@Test public void testEndHandWithElimination(){
  Game game=setupGame();
  HandEntity hand=handService.startNewHand(game);
  List<PlayerHand> players=new ArrayList<PlayerHand>();
  players.addAll(hand.getPlayers());
  Collections.sort(players);
  assertEquals(handService.getPlayerInBB(hand),players.get(2).getPlayer());
  players.get(2).getPlayer().setChips(0);
  flushAndClear();
  game=gameDao.findById(game.getId());
  handService.endHand(game.getCurrentHand());
  hand=handService.startNewHand(game);
  assertEquals("String_Node_Str",players.size() - 1,hand.getPlayers().size());
  assertEquals(game.getPlayerInBTN(),players.get(1).getPlayer());
  assertEquals(players.get(3).getPlayer(),handService.getPlayerInSB(hand));
  assertEquals(players.get(0).getPlayer(),handService.getPlayerInBB(hand));
}
Program: 26502
Project: 26502
Buggy source:
public static DesfireFileSettings selectAppFile(DesfireProtocol tag,int appID,int fileID){
  try {
    tag.selectApp(appID);
  }
 catch (  DesfireException e) {
    System.out.println("String_Node_Str");
    return null;
  }
  try {
    return tag.getFileSettings(1);
  }
 catch (  DesfireException e) {
    System.out.println("String_Node_Str");
    return null;
  }
}

Fixed version (ground truth):
public static DesfireFileSettings selectAppFile(DesfireProtocol tag,int appID,int fileID){
  try {
    tag.selectApp(appID);
  }
 catch (  DesfireException e) {
    System.out.println("String_Node_Str");
    return null;
  }
  try {
    return tag.getFileSettings(fileID);
  }
 catch (  DesfireException e) {
    System.out.println("String_Node_Str");
    return null;
  }
}
Program: 26503
Project: 26503
Buggy source:
private static String create(Class<?> cls,Object target){
  final String name=tryGetName(cls,target);
  return Strings.isNullOrEmpty(name) ? "String_Node_Str" : name.replaceAll("String_Node_Str","String_Node_Str").toLowerCase();
}

Fixed version (ground truth):
private static String create(Class<?> cls,Object target){
  final String name=tryGetName(cls,target);
  return Strings.isNullOrEmpty(name) ? "String_Node_Str" : name.replaceAll("String_Node_Str","String_Node_Str").toLowerCase(Locale.ENGLISH);
}
Program: 26504
Project: 26504
Buggy source:
@Override public boolean isBlacklisted(Class<?> teClass){
  final String teClassName=teClass.getName().toLowerCase();
  if (fullBlacklist.contains(teClassName))   return true;
  if (teClass.isAnnotationPresent(Ignore.class)) {
    fullBlacklist.add(teClassName);
    return true;
  }
  try {
    teClass.getField("String_Node_Str");
    fullBlacklist.add(teClassName);
    return true;
  }
 catch (  NoSuchFieldException e) {
  }
catch (  Throwable t) {
    Log.warn(t,"String_Node_Str",teClass);
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean isBlacklisted(Class<?> teClass){
  final String teClassName=teClass.getName().toLowerCase(Locale.ENGLISH);
  if (fullBlacklist.contains(teClassName))   return true;
  if (teClass.isAnnotationPresent(Ignore.class)) {
    fullBlacklist.add(teClassName);
    return true;
  }
  try {
    teClass.getField("String_Node_Str");
    fullBlacklist.add(teClassName);
    return true;
  }
 catch (  NoSuchFieldException e) {
  }
catch (  Throwable t) {
    Log.warn(t,"String_Node_Str",teClass);
  }
  return false;
}
Program: 26505
Project: 26505
Buggy source:
@SubscribeEvent public void onConfigChange(ConfigurationChange evt){
  if (evt.check("String_Node_Str","String_Node_Str")) {
    fullBlacklist=Sets.newHashSet(imcBlacklist);
    for (    String cls : Config.teBlacklist)     fullBlacklist.add(cls.toLowerCase());
  }
}

Fixed version (ground truth):
@SubscribeEvent public void onConfigChange(ConfigurationChange evt){
  if (evt.check("String_Node_Str","String_Node_Str")) {
    fullBlacklist=Sets.newHashSet(imcBlacklist);
    for (    String cls : Config.teBlacklist)     fullBlacklist.add(cls.toLowerCase(Locale.ENGLISH));
  }
}
Program: 26506
Project: 26506
Buggy source:
public static String getRawNameForStack(ItemStack is){
  try {
    return is.getUnlocalizedName().toLowerCase();
  }
 catch (  Exception e) {
  }
  return "String_Node_Str";
}

Fixed version (ground truth):
public static String getRawNameForStack(ItemStack is){
  try {
    return is.getUnlocalizedName().toLowerCase(Locale.ENGLISH);
  }
 catch (  Exception e) {
  }
  return "String_Node_Str";
}
Program: 26507
Project: 26507
Buggy source:
public void signalEvent(){
  Preconditions.checkState(error != null || result != null,"String_Node_Str");
  if (nobodyLovesMe) {
    Log.warn("String_Node_Str",transactionId);
  }
 else {
    try {
      access.queueEvent(SYNC_EVENT,wrap(transactionId));
    }
 catch (    Exception e) {
      Log.warn(e,"String_Node_Str");
    }
  }
}

Fixed version (ground truth):
public void signalEvent(){
  Preconditions.checkState(error != null || result != null,"String_Node_Str");
  if (nobodyLovesMe) {
    Log.warn("String_Node_Str",transactionId);
  }
 else {
    try {
      access.queueEvent(SYNC_EVENT,wrap(transactionId));
    }
 catch (    Exception e) {
      Log.warn(e,"String_Node_Str",transactionId);
    }
  }
}
Program: 26508
Project: 26508
Buggy source:
@OnTick @Freeform @Alias("String_Node_Str") @LuaCallable(returnTypes=LuaType.NUMBER,description="String_Node_Str") public int pullItem(@Named("String_Node_Str") IInventory target,@Arg(type=LuaType.STRING,name="String_Node_Str",description="String_Node_Str") ForgeDirection direction,@Arg(type=LuaType.NUMBER,name="String_Node_Str",description="String_Node_Str") int slot,@Optionals @Arg(type=LuaType.NUMBER,name="String_Node_Str",description="String_Node_Str") Integer maxAmount,@Arg(type=LuaType.NUMBER,name="String_Node_Str",description="String_Node_Str") Integer intoSlot){
  Preconditions.checkArgument(direction != null && direction != ForgeDirection.UNKNOWN,"String_Node_Str");
  TileEntity te=(TileEntity)target;
  IInventory otherInventory=InventoryUtils.getInventory(te.worldObj,te.xCoord,te.yCoord,te.zCoord,direction);
  if (otherInventory == null || otherInventory == target)   return 0;
  if (maxAmount == null)   maxAmount=64;
  if (intoSlot == null)   intoSlot=1;
  return InventoryUtils.moveItemInto(otherInventory,slot - 1,InventoryUtils.getInventory(target),intoSlot - 1,maxAmount,direction.getOpposite(),true);
}

Fixed version (ground truth):
@OnTick @Freeform @Alias("String_Node_Str") @LuaCallable(returnTypes=LuaType.NUMBER,description="String_Node_Str") public int pullItem(@Named("String_Node_Str") IInventory target,@Arg(type=LuaType.STRING,name="String_Node_Str",description="String_Node_Str") ForgeDirection direction,@Arg(type=LuaType.NUMBER,name="String_Node_Str",description="String_Node_Str") int slot,@Optionals @Arg(type=LuaType.NUMBER,name="String_Node_Str",description="String_Node_Str") Integer maxAmount,@Arg(type=LuaType.NUMBER,name="String_Node_Str",description="String_Node_Str") Integer intoSlot){
  Preconditions.checkArgument(direction != null && direction != ForgeDirection.UNKNOWN,"String_Node_Str");
  TileEntity te=(TileEntity)target;
  IInventory otherInventory=InventoryUtils.getInventory(te.worldObj,te.xCoord,te.yCoord,te.zCoord,direction);
  if (otherInventory == null || otherInventory == target)   return 0;
  if (maxAmount == null)   maxAmount=64;
  if (intoSlot == null)   intoSlot=0;
  return InventoryUtils.moveItemInto(otherInventory,slot - 1,InventoryUtils.getInventory(target),intoSlot - 1,maxAmount,direction.getOpposite(),true);
}
Program: 26509
Project: 26509
Buggy source:
@OnTick @Freeform @Alias("String_Node_Str") @LuaCallable(returnTypes=LuaType.NUMBER,description="String_Node_Str") public int pushItem(@Named("String_Node_Str") IInventory target,@Arg(type=LuaType.STRING,name="String_Node_Str",description="String_Node_Str") ForgeDirection direction,@Arg(type=LuaType.NUMBER,name="String_Node_Str",description="String_Node_Str") int slot,@Optionals @Arg(type=LuaType.NUMBER,name="String_Node_Str",description="String_Node_Str") Integer maxAmount,@Arg(type=LuaType.NUMBER,name="String_Node_Str",description="String_Node_Str") Integer intoSlot){
  Preconditions.checkArgument(direction != null && direction != ForgeDirection.UNKNOWN,"String_Node_Str");
  TileEntity te=(TileEntity)target;
  IInventory otherInventory=InventoryUtils.getInventory(te.worldObj,te.xCoord,te.yCoord,te.zCoord,direction);
  if (otherInventory == null || otherInventory == target)   return 0;
  if (maxAmount == null)   maxAmount=64;
  if (intoSlot == null)   intoSlot=1;
  return InventoryUtils.moveItemInto(InventoryUtils.getInventory(target),slot - 1,otherInventory,intoSlot - 1,maxAmount,direction,true);
}

Fixed version (ground truth):
@OnTick @Freeform @Alias("String_Node_Str") @LuaCallable(returnTypes=LuaType.NUMBER,description="String_Node_Str") public int pushItem(@Named("String_Node_Str") IInventory target,@Arg(type=LuaType.STRING,name="String_Node_Str",description="String_Node_Str") ForgeDirection direction,@Arg(type=LuaType.NUMBER,name="String_Node_Str",description="String_Node_Str") int slot,@Optionals @Arg(type=LuaType.NUMBER,name="String_Node_Str",description="String_Node_Str") Integer maxAmount,@Arg(type=LuaType.NUMBER,name="String_Node_Str",description="String_Node_Str") Integer intoSlot){
  Preconditions.checkArgument(direction != null && direction != ForgeDirection.UNKNOWN,"String_Node_Str");
  TileEntity te=(TileEntity)target;
  IInventory otherInventory=InventoryUtils.getInventory(te.worldObj,te.xCoord,te.yCoord,te.zCoord,direction);
  if (otherInventory == null || otherInventory == target)   return 0;
  if (maxAmount == null)   maxAmount=64;
  if (intoSlot == null)   intoSlot=0;
  return InventoryUtils.moveItemInto(InventoryUtils.getInventory(target),slot - 1,otherInventory,intoSlot - 1,maxAmount,direction,true);
}
Program: 26510
Project: 26510
Buggy source:
@LuaMethod(returnType=LuaType.TABLE,onTick=false,description="String_Node_Str",args={@Arg(type=LuaType.NUMBER,name="String_Node_Str",description="String_Node_Str")}) public Map getMinecartData(IComputerAccess computer,ISensorEnvironment env,int minecartId){
  ArrayList<Integer> surroundingCarts=getMobIds(computer,env);
  if (surroundingCarts.contains(minecartId)) {
    Entity cart=env.getWorld().getEntityByID(minecartId);
    return EntityUtils.entityToMap(cart,env.getLocation());
  }
  return null;
}

Fixed version (ground truth):
@LuaMethod(returnType=LuaType.TABLE,onTick=false,description="String_Node_Str",args={@Arg(type=LuaType.NUMBER,name="String_Node_Str",description="String_Node_Str")}) public Map getMinecartData(IComputerAccess computer,ISensorEnvironment env,int minecartId){
  ArrayList<Integer> surroundingCarts=getMinecartIds(computer,env);
  if (surroundingCarts.contains(minecartId)) {
    Entity cart=env.getWorld().getEntityByID(minecartId);
    return EntityUtils.entityToMap(cart,env.getLocation());
  }
  return null;
}
Program: 26511
Project: 26511
Buggy source:
public static void entityToMap(Entity entity,HashMap map,Vec3 relativePos){
}

Fixed version (ground truth):
public static void entityToMap(Entity entity,HashMap map,Vec3 relativePos){
  if (entity instanceof IEnergyTransfer) {
    IEnergyTransfer cart=(IEnergyTransfer)entity;
    map.put("String_Node_Str",cart.getCapacity());
    map.put("String_Node_Str",cart.getEnergy());
    map.put("String_Node_Str",cart.getTier());
    map.put("String_Node_Str",cart.getTransferLimit());
  }
  if (entity instanceof IExplosiveCart) {
    IExplosiveCart cart=(IExplosiveCart)entity;
    map.put("String_Node_Str",cart.isPrimed());
    map.put("String_Node_Str",cart.getFuse());
  }
  if (entity instanceof ILinkableCart) {
    ILinkableCart cart=(ILinkableCart)entity;
    EntityMinecart minecart=(EntityMinecart)entity;
    boolean linkable=cart.isLinkable();
    map.put("String_Node_Str",linkable);
    if (linkable) {
      int cartCount=CartTools.linkageManager.countCartsInTrain(minecart);
      map.put("String_Node_Str",cartCount);
    }
    boolean hasOwner=CartTools.doesCartHaveOwner(minecart);
    map.put("String_Node_Str",hasOwner);
    if (hasOwner) {
      map.put("String_Node_Str",CartTools.getCartOwner(minecart));
    }
  }
  if (entity instanceof ILiquidTransfer) {
    ILiquidTransfer cart=(ILiquidTransfer)entity;
    map.put("String_Node_Str",cart.isFilling());
  }
  if (entity instanceof IPaintedCart) {
    IPaintedCart cart=(IPaintedCart)entity;
    map.put("String_Node_Str",cart.getPrimaryColor());
    map.put("String_Node_Str",cart.getSecondaryColor());
  }
  if (entity instanceof IRefuelableCart) {
    IRefuelableCart cart=(IRefuelableCart)entity;
    map.put("String_Node_Str",cart.needsRefuel());
  }
  if (entity instanceof IRoutableCart) {
    IRoutableCart cart=(IRoutableCart)entity;
    map.put("String_Node_Str",cart.getDestination());
  }
}
Program: 26512
Project: 26512
Buggy source:
protected Object[] formatParameters(IComputerAccess computer,MethodDeclaration method,Object[] arguments) throws Exception {
  Arg[] requiredParameters=method.getRequiredParameters();
  if (arguments.length != requiredParameters.length) {
    throw new Exception(String.format("String_Node_Str",requiredParameters.length));
  }
  for (int i=0; i < requiredParameters.length; i++) {
    if (!requiredParameters[i].type().getJavaType().isAssignableFrom(arguments[i].getClass())) {
      throw new Exception(String.format("String_Node_Str",i + 1,requiredParameters[i].name(),requiredParameters[i].type().getName()));
    }
  }
  Class[] requiredJavaParameters=method.getRequiredJavaParameters();
  for (int i=0; i < arguments.length; i++) {
    arguments[i]=TypeConversionRegistry.fromLua(arguments[i],requiredJavaParameters[i]);
  }
  Object[] newArgs=new Object[arguments.length + 2];
  System.arraycopy(arguments,0,newArgs,2,arguments.length);
  newArgs[0]=computer;
  newArgs[1]=getTargetObject();
  return newArgs;
}

Fixed version (ground truth):
protected Object[] formatParameters(IComputerAccess computer,MethodDeclaration method,Object[] arguments) throws Exception {
  Arg[] requiredParameters=method.getRequiredParameters();
  if (arguments.length != requiredParameters.length) {
    throw new Exception(String.format("String_Node_Str",requiredParameters.length));
  }
  for (int i=0; i < requiredParameters.length; i++) {
    if (!requiredParameters[i].type().getJavaType().isAssignableFrom(arguments[i].getClass())) {
      throw new Exception(String.format("String_Node_Str",i + 1,requiredParameters[i].name(),requiredParameters[i].type().getName()));
    }
  }
  Class<?>[] requiredJavaParameters=method.getRequiredJavaParameters();
  for (int i=0; i < arguments.length; i++) {
    arguments[i]=TypeConversionRegistry.fromLua(arguments[i],requiredJavaParameters[i]);
  }
  Object[] newArgs=new Object[arguments.length + 2];
  System.arraycopy(arguments,0,newArgs,2,arguments.length);
  newArgs[0]=computer;
  newArgs[1]=getTargetObject();
  return newArgs;
}
Program: 26513
Project: 26513
Buggy source:
protected Object[] callOnTarget(final IComputerAccess computer,ILuaContext context,final MethodDeclaration method,World worldObj,final Object target,final Object[] parameters) throws Exception {
  if (method.onTick()) {
    Future callback=TickHandler.addTickCallback(worldObj,new Callable(){
      @Override public Object call() throws Exception {
        try {
          Object[] response=formatResponse(method.getMethod().invoke(target,parameters));
          computer.queueEvent(EVENT_SUCCESS,response);
        }
 catch (        Throwable e) {
          computer.queueEvent(EVENT_ERROR,new Object[]{getMessageForThrowable(e)});
        }
        return null;
      }
    }
);
    while (true) {
      Object[] event=context.pullEvent(null);
      String eventName=(String)event[0];
      if (eventName.equals(EVENT_ERROR)) {
        throw new Exception((String)event[1]);
      }
 else       if (eventName.equals(EVENT_SUCCESS)) {
        Object[] response=new Object[event.length - 1];
        System.arraycopy(event,1,response,0,response.length);
        return response;
      }
    }
  }
 else {
    return formatResponse(method.getMethod().invoke(target,parameters));
  }
}

Fixed version (ground truth):
protected Object[] callOnTarget(final IComputerAccess computer,ILuaContext context,final MethodDeclaration method,World worldObj,final Object target,final Object[] parameters) throws Exception {
  if (method.onTick()) {
    TickHandler.addTickCallback(worldObj,new Callable<Object>(){
      @Override public Object call() throws Exception {
        try {
          Object[] response=formatResponse(method.getMethod().invoke(target,parameters));
          computer.queueEvent(EVENT_SUCCESS,response);
        }
 catch (        Throwable e) {
          computer.queueEvent(EVENT_ERROR,new Object[]{getMessageForThrowable(e)});
        }
        return null;
      }
    }
);
    while (true) {
      Object[] event=context.pullEvent(null);
      String eventName=(String)event[0];
      if (eventName.equals(EVENT_ERROR)) {
        throw new Exception((String)event[1]);
      }
 else       if (eventName.equals(EVENT_SUCCESS)) {
        Object[] response=new Object[event.length - 1];
        System.arraycopy(event,1,response,0,response.length);
        return response;
      }
    }
  }
 else {
    try {
      Object[] response=formatResponse(method.getMethod().invoke(target,parameters));
      return response;
    }
 catch (    Throwable e) {
      throw new Exception(getMessageForThrowable(e));
    }
  }
}
Program: 26514
Project: 26514
Buggy source:
@LuaMethod(description="String_Node_Str",returnType=LuaType.NUMBER,args={@Arg(type=LuaType.TABLE,name="String_Node_Str",description="String_Node_Str"),@Arg(type=LuaType.STRING,name="String_Node_Str",description="String_Node_Str")}) public int extractItem(IComputerAccess computer,Object te,ItemStack stack,ForgeDirection direction){
  if (stack == null) {
    return 0;
  }
  IAEItemStack request=Util.createItemStack(stack);
  if (request == null) {
    return 0;
  }
  IAEItemStack returned=getGrid(te).getCellArray().extractItems(request);
  if (returned == null) {
    return 0;
  }
  IAEItemStack giveBack=null;
  int requestAmount=stack.stackSize;
  if (!(te instanceof TileEntity)) {
    return 0;
  }
  TileEntity tile=(TileEntity)te;
  IInventory inventory=InventoryUtils.getInventory(tile.worldObj,tile.xCoord,tile.yCoord,tile.zCoord,direction);
  if (inventory == null) {
    giveBack=returned.copy();
  }
 else {
    ItemStack returnedStack=returned.getItemStack();
    InventoryUtils.insertItemIntoInventory(inventory,returnedStack);
    giveBack=Util.createItemStack(returnedStack.copy());
  }
  if (giveBack != null) {
    getGrid(te).getCellArray().addItems(giveBack);
  }
  if (giveBack != null) {
    return requestAmount - (int)giveBack.getStackSize();
  }
  return requestAmount;
}

Fixed version (ground truth):
@LuaMethod(description="String_Node_Str",returnType=LuaType.NUMBER,args={@Arg(type=LuaType.TABLE,name="String_Node_Str",description="String_Node_Str"),@Arg(type=LuaType.STRING,name="String_Node_Str",description="String_Node_Str")}) public int extractItem(IComputerAccess computer,Object te,ItemStack stack,ForgeDirection direction){
  if (stack == null) {
    return 0;
  }
  IAEItemStack request=Util.createItemStack(stack);
  if (request == null) {
    return 0;
  }
  IAEItemStack returned=getGrid(te).getCellArray().extractItems(request);
  if (returned == null) {
    return 0;
  }
  IAEItemStack giveBack=null;
  int requestAmount=stack.stackSize;
  if (!(te instanceof TileEntity)) {
    return 0;
  }
  TileEntity tile=(TileEntity)te;
  IInventory inventory=InventoryUtils.getInventory(tile.worldObj,tile.xCoord,tile.yCoord,tile.zCoord,direction);
  if (inventory == null) {
    giveBack=returned.copy();
  }
 else {
    ItemStack returnedStack=returned.getItemStack();
    InventoryUtils.insertItemIntoInventory(inventory,returnedStack,direction.getOpposite());
    giveBack=Util.createItemStack(returnedStack.copy());
  }
  if (giveBack != null) {
    getGrid(te).getCellArray().addItems(giveBack);
  }
  if (giveBack != null) {
    return requestAmount - (int)giveBack.getStackSize();
  }
  return requestAmount;
}
Program: 26515
Project: 26515
Buggy source:
@LuaMethod(returnType=LuaType.NUMBER,description="String_Node_Str",args={@Arg(type=LuaType.STRING,name="String_Node_Str",description="String_Node_Str"),@Arg(type=LuaType.NUMBER,name="String_Node_Str",description="String_Node_Str"),@Arg(type=LuaType.NUMBER,name="String_Node_Str",description="String_Node_Str")}) public int pullItem(IComputerAccess computer,IInventory target,ForgeDirection direction,int slot,int maxAmount) throws Exception {
  int merged=0;
  if (target instanceof TileEntity) {
    TileEntity tile=(TileEntity)target;
    if (direction == ForgeDirection.UNKNOWN) {
      return 0;
    }
    TileEntity targetTile=BlockUtils.getTileInDirection(tile,direction);
    if (targetTile == null || !(targetTile instanceof IInventory)) {
      throw new Exception("String_Node_Str");
    }
    merged=InventoryUtils.moveItem((IInventory)targetTile,slot - 1,(IInventory)tile,maxAmount);
  }
  return merged;
}

Fixed version (ground truth):
@LuaMethod(returnType=LuaType.NUMBER,description="String_Node_Str",args={@Arg(type=LuaType.STRING,name="String_Node_Str",description="String_Node_Str"),@Arg(type=LuaType.NUMBER,name="String_Node_Str",description="String_Node_Str"),@Arg(type=LuaType.NUMBER,name="String_Node_Str",description="String_Node_Str")}) public int pullItem(IComputerAccess computer,IInventory target,ForgeDirection direction,int slot,int maxAmount) throws Exception {
  int merged=0;
  if (target instanceof TileEntity) {
    TileEntity tile=(TileEntity)target;
    if (direction == ForgeDirection.UNKNOWN) {
      return 0;
    }
    TileEntity targetTile=BlockUtils.getTileInDirection(tile,direction);
    if (targetTile == null || !(targetTile instanceof IInventory)) {
      throw new Exception("String_Node_Str");
    }
    merged=InventoryUtils.moveItem((IInventory)targetTile,slot - 1,(IInventory)tile,maxAmount,direction.getOpposite());
  }
  return merged;
}
Program: 26516
Project: 26516
Buggy source:
@LuaMethod(returnType=LuaType.NUMBER,description="String_Node_Str",args={@Arg(type=LuaType.STRING,name="String_Node_Str",description="String_Node_Str"),@Arg(type=LuaType.NUMBER,name="String_Node_Str",description="String_Node_Str"),@Arg(type=LuaType.NUMBER,name="String_Node_Str",description="String_Node_Str"),@Arg(type=LuaType.NUMBER,name="String_Node_Str",description="String_Node_Str")}) public int pushItemIntoSlot(IComputerAccess computer,IInventory target,ForgeDirection direction,int slot,int maxAmount,int intoSlot) throws Exception {
  int merged=0;
  boolean pull=true;
  if (target instanceof TileEntity) {
    TileEntity tile=(TileEntity)target;
    if (direction == ForgeDirection.UNKNOWN) {
      return 0;
    }
    TileEntity targetTile=BlockUtils.getTileInDirection(tile,direction);
    if (targetTile == null || !(targetTile instanceof IInventory)) {
      throw new Exception("String_Node_Str");
    }
    merged=InventoryUtils.moveItemInto((IInventory)tile,slot - 1,(IInventory)targetTile,intoSlot - 1,maxAmount);
  }
  return merged;
}

Fixed version (ground truth):
@LuaMethod(returnType=LuaType.NUMBER,description="String_Node_Str",args={@Arg(type=LuaType.STRING,name="String_Node_Str",description="String_Node_Str"),@Arg(type=LuaType.NUMBER,name="String_Node_Str",description="String_Node_Str"),@Arg(type=LuaType.NUMBER,name="String_Node_Str",description="String_Node_Str"),@Arg(type=LuaType.NUMBER,name="String_Node_Str",description="String_Node_Str")}) public int pushItemIntoSlot(IComputerAccess computer,IInventory target,ForgeDirection direction,int slot,int maxAmount,int intoSlot) throws Exception {
  int merged=0;
  boolean pull=true;
  if (target instanceof TileEntity) {
    TileEntity tile=(TileEntity)target;
    if (direction == ForgeDirection.UNKNOWN) {
      return 0;
    }
    TileEntity targetTile=BlockUtils.getTileInDirection(tile,direction);
    if (targetTile == null || !(targetTile instanceof IInventory)) {
      throw new Exception("String_Node_Str");
    }
    merged=InventoryUtils.moveItemInto((IInventory)tile,slot - 1,(IInventory)targetTile,intoSlot - 1,maxAmount,direction.getOpposite());
  }
  return merged;
}
Program: 26517
Project: 26517
Buggy source:
@LuaMethod(returnType=LuaType.NUMBER,description="String_Node_Str",args={@Arg(type=LuaType.STRING,name="String_Node_Str",description="String_Node_Str"),@Arg(type=LuaType.NUMBER,name="String_Node_Str",description="String_Node_Str"),@Arg(type=LuaType.NUMBER,name="String_Node_Str",description="String_Node_Str"),@Arg(type=LuaType.NUMBER,name="String_Node_Str",description="String_Node_Str")}) public int pullItemIntoSlot(IComputerAccess computer,IInventory target,ForgeDirection direction,int slot,int maxAmount,int intoSlot) throws Exception {
  int merged=0;
  if (target instanceof TileEntity) {
    TileEntity tile=(TileEntity)target;
    if (direction == ForgeDirection.UNKNOWN) {
      return 0;
    }
    TileEntity targetTile=BlockUtils.getTileInDirection(tile,direction);
    if (targetTile == null || !(targetTile instanceof IInventory)) {
      throw new Exception("String_Node_Str");
    }
    merged=InventoryUtils.moveItemInto((IInventory)targetTile,slot - 1,(IInventory)tile,intoSlot - 1,maxAmount);
  }
  return merged;
}

Fixed version (ground truth):
@LuaMethod(returnType=LuaType.NUMBER,description="String_Node_Str",args={@Arg(type=LuaType.STRING,name="String_Node_Str",description="String_Node_Str"),@Arg(type=LuaType.NUMBER,name="String_Node_Str",description="String_Node_Str"),@Arg(type=LuaType.NUMBER,name="String_Node_Str",description="String_Node_Str"),@Arg(type=LuaType.NUMBER,name="String_Node_Str",description="String_Node_Str")}) public int pullItemIntoSlot(IComputerAccess computer,IInventory target,ForgeDirection direction,int slot,int maxAmount,int intoSlot) throws Exception {
  int merged=0;
  if (target instanceof TileEntity) {
    TileEntity tile=(TileEntity)target;
    if (direction == ForgeDirection.UNKNOWN) {
      return 0;
    }
    TileEntity targetTile=BlockUtils.getTileInDirection(tile,direction);
    if (targetTile == null || !(targetTile instanceof IInventory)) {
      throw new Exception("String_Node_Str");
    }
    merged=InventoryUtils.moveItemInto((IInventory)targetTile,slot - 1,(IInventory)tile,intoSlot - 1,maxAmount,direction.getOpposite());
  }
  return merged;
}
Program: 26518
Project: 26518
Buggy source:
@LuaMethod(returnType=LuaType.VOID,description="String_Node_Str") public void condenseItems(IComputerAccess computer,IInventory target) throws Exception {
  IInventory invent=(IInventory)target;
  ArrayList<ItemStack> stacks=new ArrayList<ItemStack>();
  for (int i=0; i < invent.getSizeInventory(); i++) {
    ItemStack sta=invent.getStackInSlot(i);
    if (sta != null) {
      stacks.add(sta.copy());
    }
    invent.setInventorySlotContents(i,null);
  }
  for (  ItemStack stack : stacks) {
    InventoryUtils.insertItemIntoInventory(invent,stack);
  }
}

Fixed version (ground truth):
@LuaMethod(returnType=LuaType.VOID,description="String_Node_Str") public void condenseItems(IComputerAccess computer,IInventory target) throws Exception {
  IInventory invent=(IInventory)target;
  ArrayList<ItemStack> stacks=new ArrayList<ItemStack>();
  for (int i=0; i < invent.getSizeInventory(); i++) {
    ItemStack sta=invent.getStackInSlot(i);
    if (sta != null) {
      stacks.add(sta.copy());
    }
    invent.setInventorySlotContents(i,null);
  }
  for (  ItemStack stack : stacks) {
    InventoryUtils.insertItemIntoInventory(invent,stack,ForgeDirection.UNKNOWN);
  }
}
Program: 26519
Project: 26519
Buggy source:
@LuaMethod(returnType=LuaType.NUMBER,description="String_Node_Str",args={@Arg(type=LuaType.STRING,name="String_Node_Str",description="String_Node_Str"),@Arg(type=LuaType.NUMBER,name="String_Node_Str",description="String_Node_Str"),@Arg(type=LuaType.NUMBER,name="String_Node_Str",description="String_Node_Str")}) public int pushItem(IComputerAccess computer,IInventory target,ForgeDirection direction,int slot,int maxAmount) throws Exception {
  int merged=0;
  if (target instanceof TileEntity) {
    TileEntity tile=(TileEntity)target;
    if (direction == ForgeDirection.UNKNOWN) {
      return 0;
    }
    TileEntity targetTile=BlockUtils.getTileInDirection(tile,direction);
    if (targetTile == null || !(targetTile instanceof IInventory)) {
      throw new Exception("String_Node_Str");
    }
    merged=InventoryUtils.moveItem((IInventory)tile,slot - 1,(IInventory)targetTile,maxAmount);
  }
  return merged;
}

Fixed version (ground truth):
@LuaMethod(returnType=LuaType.NUMBER,description="String_Node_Str",args={@Arg(type=LuaType.STRING,name="String_Node_Str",description="String_Node_Str"),@Arg(type=LuaType.NUMBER,name="String_Node_Str",description="String_Node_Str"),@Arg(type=LuaType.NUMBER,name="String_Node_Str",description="String_Node_Str")}) public int pushItem(IComputerAccess computer,IInventory target,ForgeDirection direction,int slot,int maxAmount) throws Exception {
  int merged=0;
  if (target instanceof TileEntity) {
    TileEntity tile=(TileEntity)target;
    if (direction == ForgeDirection.UNKNOWN) {
      return 0;
    }
    TileEntity targetTile=BlockUtils.getTileInDirection(tile,direction);
    if (targetTile == null || !(targetTile instanceof IInventory)) {
      throw new Exception("String_Node_Str");
    }
    merged=InventoryUtils.moveItem((IInventory)tile,slot - 1,(IInventory)targetTile,maxAmount,direction.getOpposite());
  }
  return merged;
}
Program: 26520
Project: 26520
Buggy source:
public static int moveItem(IInventory fromInventory,int slot,IInventory targetInventory,int maxAmount){
  int merged=0;
  ItemStack stack=fromInventory.getStackInSlot(slot);
  if (stack == null) {
    return 0;
  }
  ItemStack clonedStack=stack.copy();
  clonedStack.stackSize=Math.min(clonedStack.stackSize,maxAmount);
  int amountToMerge=clonedStack.stackSize;
  InventoryUtils.insertItemIntoInventory(targetInventory,clonedStack);
  merged=(amountToMerge - clonedStack.stackSize);
  fromInventory.decrStackSize(slot,merged);
  return merged;
}

Fixed version (ground truth):
public static int moveItem(IInventory fromInventory,int slot,IInventory targetInventory,int maxAmount,ForgeDirection side){
  int merged=0;
  ItemStack stack=fromInventory.getStackInSlot(slot);
  if (stack == null) {
    return 0;
  }
  if (fromInventory instanceof ISidedInventory) {
    if (((ISidedInventory)fromInventory).canExtractItem(slot,stack,side.ordinal())) {
      return 0;
    }
  }
  ItemStack clonedStack=stack.copy();
  clonedStack.stackSize=Math.min(clonedStack.stackSize,maxAmount);
  int amountToMerge=clonedStack.stackSize;
  InventoryUtils.insertItemIntoInventory(targetInventory,clonedStack,side.getOpposite());
  merged=(amountToMerge - clonedStack.stackSize);
  fromInventory.decrStackSize(slot,merged);
  return merged;
}
Program: 26521
Project: 26521
Buggy source:
public static void insertItemIntoInventory(IInventory inventory,ItemStack stack){
  int i=0;
  while (stack.stackSize > 0 && i < inventory.getSizeInventory()) {
    tryMergeStacks(inventory,i,stack);
    i++;
  }
}

Fixed version (ground truth):
public static void insertItemIntoInventory(IInventory inventory,ItemStack stack,ForgeDirection side){
  int i=0;
  while (stack.stackSize > 0 && i < inventory.getSizeInventory()) {
    if (side != ForgeDirection.UNKNOWN && inventory instanceof ISidedInventory) {
      if (!((ISidedInventory)inventory).canInsertItem(i,stack,side.ordinal())) {
        i++;
        continue;
      }
    }
    tryMergeStacks(inventory,i,stack);
    i++;
  }
}
Program: 26522
Project: 26522
Buggy source:
public static int moveItemInto(IInventory fromInventory,int slot,IInventory targetInventory,int intoSlot,int maxAmount){
  int merged=0;
  ItemStack stack=fromInventory.getStackInSlot(slot);
  if (stack == null) {
    return merged;
  }
  ItemStack clonedStack=stack.copy();
  clonedStack.stackSize=Math.min(clonedStack.stackSize,maxAmount);
  int amountToMerge=clonedStack.stackSize;
  InventoryUtils.tryMergeStacks(targetInventory,intoSlot,clonedStack);
  merged=(amountToMerge - clonedStack.stackSize);
  fromInventory.decrStackSize(slot,merged);
  return merged;
}

Fixed version (ground truth):
public static int moveItemInto(IInventory fromInventory,int slot,IInventory targetInventory,int intoSlot,int maxAmount,ForgeDirection direction){
  if (!InventoryUtils.canMoveItem(fromInventory,targetInventory,slot,intoSlot,direction)) {
    return 0;
  }
  int merged=0;
  ItemStack stack=fromInventory.getStackInSlot(slot);
  if (stack == null) {
    return merged;
  }
  ItemStack clonedStack=stack.copy();
  clonedStack.stackSize=Math.min(clonedStack.stackSize,maxAmount);
  int amountToMerge=clonedStack.stackSize;
  InventoryUtils.tryMergeStacks(targetInventory,intoSlot,clonedStack);
  merged=(amountToMerge - clonedStack.stackSize);
  fromInventory.decrStackSize(slot,merged);
  return merged;
}
Program: 26523
Project: 26523
Buggy source:
@LuaMethod public boolean suck(IComputerAccess computer,IRobot robot){
  World worldObj=robot.getWorld();
  Vec3 location=robot.getLocation();
  IInventory inventory=robot.getInventory();
  List<EntityItem> entities=worldObj.getEntitiesWithinAABB(EntityItem.class,AxisAlignedBB.getAABBPool().getAABB(location.xCoord - 2,location.yCoord - 2,location.zCoord - 2,location.xCoord + 3,location.yCoord + 3,location.zCoord + 3));
  for (  EntityItem entity : entities) {
    if (entity.isDead) {
      continue;
    }
    ItemStack stack=entity.getEntityItem();
    if (stack != null) {
      InventoryUtils.insertItemIntoInventory(inventory,stack);
      if (stack.stackSize == 0) {
        entity.setDead();
      }
    }
  }
  return true;
}

Fixed version (ground truth):
@LuaMethod public boolean suck(IComputerAccess computer,IRobot robot){
  World worldObj=robot.getWorld();
  Vec3 location=robot.getLocation();
  IInventory inventory=robot.getInventory();
  List<EntityItem> entities=worldObj.getEntitiesWithinAABB(EntityItem.class,AxisAlignedBB.getAABBPool().getAABB(location.xCoord - 2,location.yCoord - 2,location.zCoord - 2,location.xCoord + 3,location.yCoord + 3,location.zCoord + 3));
  for (  EntityItem entity : entities) {
    if (entity.isDead) {
      continue;
    }
    ItemStack stack=entity.getEntityItem();
    if (stack != null) {
      InventoryUtils.insertItemIntoInventory(inventory,stack,ForgeDirection.UNKNOWN);
      if (stack.stackSize == 0) {
        entity.setDead();
      }
    }
  }
  return true;
}
Program: 26524
Project: 26524
Buggy source:
@Override public IHostedPeripheral getPeripheral(TileEntity tile){
  if (tile instanceof TileEntityCommandBlock) {
    return null;
  }
  if (tile instanceof IPeripheral) {
    return null;
  }
  if (tile == null) {
    return null;
  }
  if (tile instanceof IPeripheralProvider) {
    return ((IPeripheralProvider)tile).providePeripheral(tile.worldObj);
  }
  if (!peripherals.containsKey(tile)) {
    peripherals.put(tile,new HostedPeripheral(tile,tile.worldObj));
  }
  if (peripherals.get(tile).getMethodNames().length == 1) {
    return null;
  }
  return peripherals.get(tile);
}

Fixed version (ground truth):
@Override public IHostedPeripheral getPeripheral(TileEntity tile){
  if (tile instanceof TileEntityCommandBlock) {
    return null;
  }
  if (tile instanceof IPeripheral) {
    return null;
  }
  if (tile == null) {
    return null;
  }
  if (tile instanceof IPeripheralProvider) {
    return ((IPeripheralProvider)tile).providePeripheral(tile.worldObj);
  }
  if (!peripherals.containsKey(tile) || tile.isInvalid()) {
    peripherals.put(tile,new HostedPeripheral(tile,tile.worldObj));
  }
  if (peripherals.get(tile).getMethodNames().length == 1) {
    return null;
  }
  return peripherals.get(tile);
}
Program: 26525
Project: 26525
Buggy source:
@Override public Object[] callMethod(final IComputerAccess computer,ILuaContext context,int index,Object[] arguments) throws Exception {
  final MethodDeclaration method=methods.get(index);
  final Object[] formattedParameters=formatParameters(computer,method,arguments);
  return callOnTarget(computer,context,method,getWorldObject(),method.getTargetAdapter(),formattedParameters);
}

Fixed version (ground truth):
@Override public Object[] callMethod(final IComputerAccess computer,ILuaContext context,int index,Object[] arguments) throws Exception {
  if (getTargetObject() instanceof TileEntity) {
    TileEntity tile=(TileEntity)getTargetObject();
    targetObject=tile.worldObj.getBlockTileEntity(tile.xCoord,tile.yCoord,tile.zCoord);
  }
  final MethodDeclaration method=methods.get(index);
  final Object[] formattedParameters=formatParameters(computer,method,arguments);
  return callOnTarget(computer,context,method,getWorldObject(),method.getTargetAdapter(),formattedParameters);
}
Program: 26526
Project: 26526
Buggy source:
public static int moveItem(IInventory fromInventory,int slot,IInventory targetInventory,int maxAmount,ForgeDirection side){
  int merged=0;
  ItemStack stack=fromInventory.getStackInSlot(slot);
  if (stack == null) {
    return 0;
  }
  if (fromInventory instanceof ISidedInventory) {
    if (((ISidedInventory)fromInventory).canExtractItem(slot,stack,side.ordinal())) {
      return 0;
    }
  }
  ItemStack clonedStack=stack.copy();
  clonedStack.stackSize=Math.min(clonedStack.stackSize,maxAmount);
  int amountToMerge=clonedStack.stackSize;
  InventoryUtils.insertItemIntoInventory(targetInventory,clonedStack,side.getOpposite());
  merged=(amountToMerge - clonedStack.stackSize);
  fromInventory.decrStackSize(slot,merged);
  return merged;
}

Fixed version (ground truth):
public static int moveItem(IInventory fromInventory,int slot,IInventory targetInventory,int maxAmount,ForgeDirection side){
  int merged=0;
  ItemStack stack=fromInventory.getStackInSlot(slot);
  if (stack == null) {
    return 0;
  }
  if (fromInventory instanceof ISidedInventory) {
    if (!((ISidedInventory)fromInventory).canExtractItem(slot,stack,side.ordinal())) {
      return 0;
    }
  }
  ItemStack clonedStack=stack.copy();
  clonedStack.stackSize=Math.min(clonedStack.stackSize,maxAmount);
  int amountToMerge=clonedStack.stackSize;
  InventoryUtils.insertItemIntoInventory(targetInventory,clonedStack,side.getOpposite());
  merged=(amountToMerge - clonedStack.stackSize);
  fromInventory.decrStackSize(slot,merged);
  return merged;
}