nus-yam/ex-repair huggingface dataset:
Program: 56294
Project: 56294
Buggy source:
@Override public void insert(int elementId){
  final DoubleLinkedIntListItem handle=buckets[getRankIdx(elementId)].pushFront(elementId);
  handles[elementId]=handle;
  size++;
}

Fixed version (ground truth):
@Override public void insert(int elementId){
  buckets[getRankIdx(elementId)].pushFront(handles[elementId]);
  size++;
}
Program: 56295
Project: 56295
Buggy source:
@Override public int deleteMin(){
  while (buckets[minIdx].isEmpty()) {
    minIdx=(minIdx + 1) & MODULO_MASK;
  }
  size--;
  final int elementId=buckets[minIdx].popFront();
  return elementId;
}

Fixed version (ground truth):
@Override public int deleteMin(){
  while (buckets[minIdx].isEmpty()) {
    minIdx=(minIdx + 1) & MODULO_MASK;
  }
  size--;
  final int elementId=buckets[minIdx].popFront().value;
  return elementId;
}
Program: 56296
Project: 56296
Buggy source:
private final void initPathfinders(){
  pathfinderGrid=new PathfinderGrid();
  aStar=new HexAStar(pathfinderGrid,width,height);
  dijkstra=new DijkstraAlgorithm(pathfinderGrid,aStar,width,height);
  inAreaFinder=new InAreaFinder(pathfinderGrid,width,height);
}

Fixed version (ground truth):
private final void initPathfinders(){
  pathfinderGrid=new PathfinderGrid();
  aStar=new BucketQueueAStar(pathfinderGrid,width,height);
  dijkstra=new DijkstraAlgorithm(pathfinderGrid,aStar,width,height);
  inAreaFinder=new InAreaFinder(pathfinderGrid,width,height);
}
Program: 56297
Project: 56297
Buggy source:
/** 
 * @param args args can have no entries or <br> args[0] must be "host" or "client"
 * @throws FileNotFoundException
 * @throws IOException
 * @throws ClassNotFoundException
 */
public static void main(String[] args){
  ResourceManager.setProvider(new SwingResourceProvider());
  ManagedJSettlers game=new ManagedJSettlers();
  game.start(getGui());
  ImageProvider.getInstance().startPreloading();
}

Fixed version (ground truth):
/** 
 * @param args args can have no entries or <br> args[0] must be "host" or "client"
 * @throws FileNotFoundException
 * @throws IOException
 * @throws ClassNotFoundException
 */
public static void main(String[] args) throws FileNotFoundException, IOException, ClassNotFoundException {
  ResourceManager.setProvider(new SwingResourceProvider());
  ManagedJSettlers game=new ManagedJSettlers();
  game.start(getGui());
  ImageProvider.getInstance().startPreloading();
}
Program: 56298
Project: 56298
Buggy source:
@Override public Action replaceAction(Action action){
  if (action.getActionType() == EActionType.SELECT_POINT) {
    return new MoveToAction(((SelectAction)action).getPosition());
  }
  return super.replaceAction(action);
}

Fixed version (ground truth):
@Override public Action replaceAction(Action action){
  if (action.getActionType() == EActionType.SELECT_POINT) {
    return new PointAction(EActionType.MOVE_TO,((PointAction)action).getPosition());
  }
  return super.replaceAction(action);
}
Program: 56299
Project: 56299
Buggy source:
@Override public Action replaceAction(Action action){
  if (action.getActionType() == EActionType.SELECT_POINT) {
    return new SelectAction(((SelectAction)action).getPosition(),EActionType.SET_WORK_AREA);
  }
  return super.replaceAction(action);
}

Fixed version (ground truth):
@Override public Action replaceAction(Action action){
  if (action.getActionType() == EActionType.SELECT_POINT) {
    return new PointAction(EActionType.SET_WORK_AREA,((PointAction)action).getPosition());
  }
  return super.replaceAction(action);
}
Program: 56300
Project: 56300
Buggy source:
@SuppressWarnings("String_Node_Str") private void visualizeAlgoResult(final IBlockingProvider blockingProvider,final PartitionCalculatorAlgorithm algo){
  TestWindow.openTestWindow(new GraphicsGridAdapter(WIDTH,HEIGHT){
    @Override public int getDebugColorAt(    int x,    int y){
      int value;
      value=algo.getPartitionAt(x,y) + 1;
      return blockingProvider.isBlocked(x,y) ? Color.BLACK.getABGR() : Color.getARGB((value % 3) * 0.33f,((value / 3) % 3) * 0.33f,((value / 9) % 3) * 0.33f,1);
    }
  }
);
  try {
    Thread.sleep(60000);
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") private void visualizeAlgoResult(final IBlockingProvider blockingProvider,final PartitionCalculatorAlgorithm algo){
  TestWindow.openTestWindow(new GraphicsGridAdapter(WIDTH,HEIGHT){
    @Override public int getDebugColorAt(    int x,    int y){
      int value;
      value=algo.getPartitionAt(x,y) + 1;
      boolean isBlocked=false;
      return isBlocked ? Color.BLACK.getABGR() : Color.getARGB((value % 3) * 0.33f,((value / 3) % 3) * 0.33f,((value / 9) % 3) * 0.33f,1);
    }
  }
);
  try {
    Thread.sleep(60000);
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
}
Program: 56301
Project: 56301
Buggy source:
@Override public int getDebugColorAt(int x,int y){
  int value;
  value=algo.getPartitionAt(x,y) + 1;
  return blockingProvider.isBlocked(x,y) ? Color.BLACK.getABGR() : Color.getARGB((value % 3) * 0.33f,((value / 3) % 3) * 0.33f,((value / 9) % 3) * 0.33f,1);
}

Fixed version (ground truth):
@Override public int getDebugColorAt(int x,int y){
  int value;
  value=algo.getPartitionAt(x,y) + 1;
  boolean isBlocked=false;
  return isBlocked ? Color.BLACK.getABGR() : Color.getARGB((value % 3) * 0.33f,((value / 3) % 3) * 0.33f,((value / 9) % 3) * 0.33f,1);
}
Program: 56302
Project: 56302
Buggy source:
@Test public void testMergeAndRepresentatives(){
  short partition1=grid.createNewPartition((byte)1);
  short partition2=grid.createNewPartition((byte)1);
  short partition3=grid.createNewPartition((byte)1);
  short partition4=grid.createNewPartition((byte)1);
  short partition5=grid.createNewPartition((byte)1);
  grid.mergePartitions(partition1,partition2);
  grid.mergePartitions(partition3,partition4);
  grid.mergePartitions(partition1,partition4);
  grid.mergePartitions(partition4,partition5);
  for (int i=1; i < 5; i++) {
    assertEquals(grid.partitionRepresentative[i],grid.partitionRepresentative[i + 1]);
  }
}

Fixed version (ground truth):
@Test public void testMergeAndRepresentatives(){
  short partitions[]=new short[]{grid.createNewPartition((byte)1),grid.createNewPartition((byte)1),grid.createNewPartition((byte)1),grid.createNewPartition((byte)1),grid.createNewPartition((byte)1)};
  grid.mergePartitions(partitions[0],partitions[1]);
  grid.mergePartitions(partitions[2],partitions[3]);
  grid.mergePartitions(partitions[0],partitions[3]);
  grid.mergePartitions(partitions[3],partitions[4]);
  for (int i=0; i < partitions.length - 1; i++) {
    assertEquals(grid.partitionRepresentative[partitions[i]],grid.partitionRepresentative[partitions[i + 1]]);
  }
}
Program: 56303
Project: 56303
Buggy source:
private void startTest(){
  addTower(0,50,100,40);
  addTower(0,150,100,40);
  addTower(0,100,100,40);
  addTower(1,75,55,44);
  addTower(1,125,150,44);
  removeTower(100,100);
}

Fixed version (ground truth):
private void startTest(){
  addTower(0,82,120,40);
  addTower(0,75,85,40);
  addTower(0,125,105,40);
  addTower(0,94,71,40);
  changePlayerOfTower(82,120,1);
  changePlayerOfTower(75,85,1);
  changePlayerOfTower(125,105,1);
  changePlayerOfTower(94,71,1);
}
Program: 56304
Project: 56304
Buggy source:
@Override public byte getPlayerIdAt(int x,int y){
  return 0;
}

Fixed version (ground truth):
@Override public byte getPlayerIdAt(int x,int y){
  return grid.getPlayerIdAt(x,y);
}
Program: 56305
Project: 56305
Buggy source:
private void removeTower(int x,int y){
  grid.removeTowerAndFreeOccupiedArea(new ShortPoint2D(x,y));
}

Fixed version (ground truth):
private void removeTower(int x,int y){
  blockArea(getTowerBlockArea(x,y),false);
  grid.removeTowerAndFreeOccupiedArea(new ShortPoint2D(x,y));
}
Program: 56306
Project: 56306
Buggy source:
private PartitionsGridTestingWnd(){
  this.grid=new PartitionsGrid(WIDTH,HEIGHT,(byte)10,IPartitionsGridBlockingProvider.DEFAULT_IMPLEMENTATION);
}

Fixed version (ground truth):
private PartitionsGridTestingWnd(){
  this.grid=new PartitionsGrid(WIDTH,HEIGHT,(byte)10,new IPartitionsGridBlockingProvider(){
    @Override public boolean isBlocked(    int x,    int y){
      return blockedGrid.get(x + y * WIDTH);
    }
    @Override public void registerListener(    IBlockingChangedListener listener){
    }
  }
);
}
Program: 56307
Project: 56307
Buggy source:
@Override public boolean isBorder(int x,int y){
  return false;
}

Fixed version (ground truth):
@Override public boolean isBorder(int x,int y){
  byte playerAtPos=getPlayerIdAt(x,y);
  for (  EDirection dir : EDirection.values) {
    int currX=x + dir.gridDeltaX;
    int currY=y + dir.gridDeltaY;
    if (currX >= 0 && currY >= 0 && currX < WIDTH && currY < HEIGHT && playerAtPos != getPlayerIdAt(currX,currY)) {
      return true;
    }
  }
  return false;
}
Program: 56308
Project: 56308
Buggy source:
private void addTower(int playerId,int x,int y,int radius){
  grid.addTowerAndOccupyArea((byte)playerId,new MapCircle(new ShortPoint2D(x,y),radius));
}

Fixed version (ground truth):
private void addTower(int playerId,int x,int y,int radius){
  blockArea(getTowerBlockArea(x,y),true);
  grid.addTowerAndOccupyArea((byte)playerId,new MapCircle(new ShortPoint2D(x,y),radius));
}
Program: 56310
Project: 56310
Buggy source:
@Override public int getDebugColorAt(int x,int y){
  int value=grid.getPartitionIdAt(x,y);
  return Color.getARGB((value % 3) * 0.33f,((value / 3) % 3) * 0.33f,((value / 9) % 3) * 0.33f,1);
}

Fixed version (ground truth):
@Override public int getDebugColorAt(int x,int y){
  int value=grid.getTowerCountAt(x,y);
  return Color.getARGB((value % 3) * 0.33f,((value / 3) % 3) * 0.33f,((value / 9) % 3) * 0.33f,1);
}
Program: 56311
Project: 56311
Buggy source:
private void calculateBlockedPartitions(){
  MilliStopWatch watch=new MilliStopWatch();
  BitSet notBlockedSet=new BitSet(width * height);
  for (short y=0; y < height; y++) {
    for (short x=0; x < width; x++) {
      notBlockedSet.set(x + width * y,!landscapes[x][y].isBlocking);
    }
  }
  PartitionCalculatorAlgorithm partitionCalculator=new PartitionCalculatorAlgorithm(0,0,width,height,notBlockedSet,IBlockingProvider.DEFAULT_PROVIDER);
  partitionCalculator.calculatePartitions();
  for (short y=0; y < height; y++) {
    for (short x=0; x < width; x++) {
      blockedPartitions[x][y]=partitionCalculator.getPartitionAt(x,y);
    }
  }
  watch.stop("String_Node_Str");
  System.out.println("String_Node_Str" + partitionCalculator.getNumberOfPartitions() + "String_Node_Str");
}

Fixed version (ground truth):
private void calculateBlockedPartitions(){
  MilliStopWatch watch=new MilliStopWatch();
  BitSet notBlockedSet=new BitSet(width * height);
  for (short y=0; y < height; y++) {
    for (short x=0; x < width; x++) {
      notBlockedSet.set(x + width * y,!landscapes[x][y].isBlocking);
    }
  }
  PartitionCalculatorAlgorithm partitionCalculator=new PartitionCalculatorAlgorithm(0,0,width,height,notBlockedSet,IBlockingProvider.DEFAULT_IMPLEMENTATION);
  partitionCalculator.calculatePartitions();
  for (short y=0; y < height; y++) {
    for (short x=0; x < width; x++) {
      blockedPartitions[x][y]=partitionCalculator.getPartitionAt(x,y);
    }
  }
  watch.stop("String_Node_Str");
  System.out.println("String_Node_Str" + partitionCalculator.getNumberOfPartitions() + "String_Node_Str");
}
Program: 56312
Project: 56312
Buggy source:
private void placeAdditionalMapObjects(IBuildingsGrid grid,ShortPoint2D pos,boolean place){
  if (place) {
    grid.getMapObjectsManager().addSimpleMapObject(pos,EMapObjectType.BUILDINGSITE_SIGN,false,null);
  }
 else {
    grid.getMapObjectsManager().removeMapObjectType(pos.x,pos.y,EMapObjectType.BUILDINGSITE_SIGN);
  }
  for (  RelativePoint curr : type.getBuildmarks()) {
    if (place) {
      grid.getMapObjectsManager().addSimpleMapObject(curr.calculatePoint(pos),EMapObjectType.BUILDINGSITE_POST,false,null);
    }
 else {
      ShortPoint2D postPos=curr.calculatePoint(pos);
      grid.getMapObjectsManager().removeMapObjectType(postPos.x,postPos.y,EMapObjectType.BUILDINGSITE_POST);
    }
  }
}

Fixed version (ground truth):
protected void placeAdditionalMapObjects(IBuildingsGrid grid,ShortPoint2D pos,boolean place){
  if (place) {
    grid.getMapObjectsManager().addSimpleMapObject(pos,EMapObjectType.BUILDINGSITE_SIGN,false,null);
  }
 else {
    grid.getMapObjectsManager().removeMapObjectType(pos.x,pos.y,EMapObjectType.BUILDINGSITE_SIGN);
  }
  for (  RelativePoint curr : type.getBuildmarks()) {
    if (place) {
      grid.getMapObjectsManager().addSimpleMapObject(curr.calculatePoint(pos),EMapObjectType.BUILDINGSITE_POST,false,null);
    }
 else {
      ShortPoint2D postPos=curr.calculatePoint(pos);
      grid.getMapObjectsManager().removeMapObjectType(postPos.x,postPos.y,EMapObjectType.BUILDINGSITE_POST);
    }
  }
}
Program: 56313
Project: 56313
Buggy source:
@Override public final int getDebugColorAt(int x,int y){
  int value=partitionsGrid.getPartitionIdAt(x,y) + 1;
  return Color.getARGB((value % 3) * 0.33f,((value / 3) % 3) * 0.33f,((value / 9) % 3) * 0.33f,1);
}

Fixed version (ground truth):
@Override public final int getDebugColorAt(int x,int y){
  return flagsGrid.isMarked(x,y) ? Color.ORANGE.getARGB() : (objectsGrid.getMapObjectAt(x,y,EMapObjectType.INFORMABLE_MAP_OBJECT) != null ? Color.GREEN.getARGB() : (objectsGrid.getMapObjectAt(x,y,EMapObjectType.ATTACKABLE_TOWER) != null ? Color.RED.getARGB() : (flagsGrid.isBlocked(x,y) ? Color.BLACK.getARGB() : (flagsGrid.isProtected(x,y) ? Color.BLUE.getARGB() : 0))));
}
Program: 56314
Project: 56314
Buggy source:
@Override public void timerEvent(){
  if (health <= 0) {
    return;
  }
switch (state) {
case SLEEPING:
    return;
case DOING_NOTHING:
  if (visible && enableNothingToDo) {
    doingNothingAction();
  }
break;
case GOING_SINGLE_STEP:
case PLAYING_ACTION:
progressCurrentAction();
break;
case PATHING:
pathingAction();
break;
default :
break;
}
if (moveToRequest != null) {
switch (state) {
case PATHING:
if (progress < 1) {
break;
}
setState(ENewMovableState.DOING_NOTHING);
case DOING_NOTHING:
ShortPoint2D oldTargetPos;
if (path != null) {
oldTargetPos=path.getTargetPos();
}
 else {
oldTargetPos=null;
}
goToPos(moveToRequest);
moveToRequest=null;
if (path != null) {
this.strategy.moveToPathSet(oldTargetPos,path.getTargetPos());
}
break;
default :
break;
}
}
if (state == ENewMovableState.DOING_NOTHING) {
strategy.action();
}
}

Fixed version (ground truth):
@Override public void timerEvent(){
  if (health <= 0) {
    return;
  }
switch (state) {
case SLEEPING:
    return;
case DOING_NOTHING:
  if (visible && enableNothingToDo) {
    doingNothingAction();
  }
break;
case GOING_SINGLE_STEP:
case PLAYING_ACTION:
progressCurrentAction();
break;
case PATHING:
pathingAction();
break;
default :
break;
}
if (moveToRequest != null) {
switch (state) {
case PATHING:
if (progress < 1) {
break;
}
setState(ENewMovableState.DOING_NOTHING);
case DOING_NOTHING:
ShortPoint2D targetPos=path != null ? path.getTargetPos() : null;
ShortPoint2D oldPos=position;
boolean foundPath=goToPos(moveToRequest);
moveToRequest=null;
if (foundPath) {
this.strategy.moveToPathSet(oldPos,targetPos,path.getTargetPos());
}
break;
default :
break;
}
}
if (state == ENewMovableState.DOING_NOTHING) {
strategy.action();
}
}
Program: 56315
Project: 56315
Buggy source:
protected void moveToPathSet(@SuppressWarnings("String_Node_Str") ShortPoint2D oldTargetPos,@SuppressWarnings("String_Node_Str") ShortPoint2D targetPos){
}

Fixed version (ground truth):
/** 
 * @param oldPosition The position the movable was positioned before the new path has been calculated and the first step on the new path has been done.
 * @param oldTargetPos The target position of the old path or null if no old path was set.
 * @param targetPos The new target position.
 */
protected void moveToPathSet(@SuppressWarnings("String_Node_Str") ShortPoint2D oldPosition,@SuppressWarnings("String_Node_Str") ShortPoint2D oldTargetPos,@SuppressWarnings("String_Node_Str") ShortPoint2D targetPos){
}
Program: 56316
Project: 56316
Buggy source:
@Override protected void moveToPathSet(ShortPoint2D oldTargetPos,ShortPoint2D targetPos){
  if (targetPos != null && this.oldPathTarget != null) {
    oldPathTarget=null;
    inSaveGotoMode=false;
  }
}

Fixed version (ground truth):
@Override protected void moveToPathSet(ShortPoint2D oldPosition,ShortPoint2D oldTargetPos,ShortPoint2D targetPos){
  if (targetPos != null && this.oldPathTarget != null) {
    oldPathTarget=null;
    inSaveGotoMode=false;
  }
}
Program: 56317
Project: 56317
Buggy source:
@Override protected void moveToPathSet(ShortPoint2D oldTargetPos,ShortPoint2D targetPos){
  this.state=EPioneerState.GOING_TO_POS;
  centerPos=null;
  super.getStrategyGrid().setMarked(super.getPos(),false);
  if (oldTargetPos != null) {
    super.getStrategyGrid().setMarked(oldTargetPos,false);
  }
}

Fixed version (ground truth):
@Override protected void moveToPathSet(ShortPoint2D oldPosition,ShortPoint2D oldTargetPos,ShortPoint2D targetPos){
  this.state=EPioneerState.GOING_TO_POS;
  centerPos=null;
  super.getStrategyGrid().setMarked(oldPosition,false);
  if (oldTargetPos != null) {
    super.getStrategyGrid().setMarked(oldTargetPos,false);
  }
}
Program: 56318
Project: 56318
Buggy source:
@Override protected void moveToPathSet(ShortPoint2D oldTargetPos,ShortPoint2D targetPos){
  this.state=EPioneerState.GOING_TO_POS;
  centerPos=null;
}

Fixed version (ground truth):
@Override protected void moveToPathSet(ShortPoint2D oldPosition,ShortPoint2D oldTargetPos,ShortPoint2D targetPos){
  this.state=EPioneerState.GOING_TO_POS;
  centerPos=null;
}
Program: 56319
Project: 56319
Buggy source:
@Override public void occupyAreaByTower(Player player,MapCircle influencingArea){
  partitionsGrid.addTowerAndOccupyArea(player.playerId,influencingArea);
  bordersThread.checkPositions(influencingArea);
  landmarksCorrection.addLandmarkedPositions(influencingArea);
}

Fixed version (ground truth):
@Override public void occupyAreaByTower(Player player,MapCircle influencingArea){
  partitionsGrid.addTowerAndOccupyArea(player.playerId,influencingArea);
  checkAllPositionsForEnclosedBlockedAreas(influencingArea);
}
Program: 56320
Project: 56320
Buggy source:
@Override public final short getPartitionAt(short x,short y){
  return partitionsGrid.getPartitionIdAt(x,y);
}

Fixed version (ground truth):
@Override public final short getPartitionAt(int x,int y){
  return partitionsGrid.getPartitionIdAt(x,y);
}
Program: 56321
Project: 56321
Buggy source:
@Override public void freeAreaOccupiedByTower(ShortPoint2D towerPosition){
  Iterable<ShortPoint2D> changedPositions=partitionsGrid.removeTowerAndFreeOccupiedArea(towerPosition);
  bordersThread.checkPositions(changedPositions);
  landmarksCorrection.addLandmarkedPositions(changedPositions);
}

Fixed version (ground truth):
@Override public void freeAreaOccupiedByTower(ShortPoint2D towerPosition){
  Iterable<ShortPoint2D> positions=partitionsGrid.removeTowerAndFreeOccupiedArea(towerPosition);
  checkAllPositionsForEnclosedBlockedAreas(positions);
}
Program: 56322
Project: 56322
Buggy source:
@Override public void changePlayerAt(ShortPoint2D position,Player player){
  partitionsGrid.changePlayerAt(position,player.playerId);
  bordersThread.checkPosition(position);
  landmarksCorrection.addLandmarkedPosition(position);
}

Fixed version (ground truth):
@Override public void changePlayerAt(ShortPoint2D position,Player player){
  partitionsGrid.changePlayerAt(position,player.playerId);
  bordersThread.checkPosition(position);
  checkForEnclosedBlockedArea(position);
}
Program: 56323
Project: 56323
Buggy source:
@Override public final boolean setBuilding(ShortPoint2D position,Building newBuilding){
  if (MainGrid.this.isInBounds(position.x,position.y)) {
    FreeMapArea area=new FreeMapArea(position,newBuilding.getBuildingType().getProtectedTiles());
    if (canConstructAt(area)) {
      setProtectedState(area,true);
      mapObjectsManager.addBuildingTo(position,newBuilding);
      objectsGrid.setBuildingArea(area,newBuilding);
      return true;
    }
 else {
      return false;
    }
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
@Override public final boolean setBuilding(ShortPoint2D position,Building newBuilding){
  if (MainGrid.this.isInBounds(position.x,position.y)) {
    FreeMapArea area=new FreeMapArea(position,newBuilding.getBuildingType().getBlockedTiles());
    if (canConstructAt(area)) {
      setProtectedState(area,true);
      mapObjectsManager.addBuildingTo(position,newBuilding);
      objectsGrid.setBuildingArea(area,newBuilding);
      return true;
    }
 else {
      return false;
    }
  }
 else {
    return false;
  }
}
Program: 56324
Project: 56324
Buggy source:
public void startThreads(){
  bordersThread.start();
  fogOfWar.start(new FogOfWarGrid());
  landmarksCorrection.start();
  partitionsGrid.startThreads();
}

Fixed version (ground truth):
public void startThreads(){
  bordersThread.start();
  fogOfWar.start(new FogOfWarGrid());
  partitionsGrid.startThreads();
}
Program: 56325
Project: 56325
Buggy source:
public void stopThreads(){
  bordersThread.cancel();
  fogOfWar.cancel();
  landmarksCorrection.cancel();
  partitionsGrid.cancelThreads();
}

Fixed version (ground truth):
public void stopThreads(){
  bordersThread.cancel();
  fogOfWar.cancel();
  partitionsGrid.cancelThreads();
}
Program: 56326
Project: 56326
Buggy source:
@Override public void changePlayerOfTower(ShortPoint2D towerPosition,Player newPlayer,FreeMapArea groundArea){
  Iterable<ShortPoint2D> changedPositions=partitionsGrid.changePlayerOfTower(towerPosition,newPlayer.playerId,groundArea);
  bordersThread.checkPositions(changedPositions);
  landmarksCorrection.addLandmarkedPositions(changedPositions);
}

Fixed version (ground truth):
@Override public void changePlayerOfTower(ShortPoint2D towerPosition,Player newPlayer,FreeMapArea groundArea){
  Iterable<ShortPoint2D> positions=partitionsGrid.changePlayerOfTower(towerPosition,newPlayer.playerId,groundArea);
  checkAllPositionsForEnclosedBlockedAreas(positions);
}
Program: 56327
Project: 56327
Buggy source:
@Override public final int getDebugColorAt(int x,int y){
  int value=partitionsGrid.getTowerCountAt(x,y) + 1;
  return Color.getABGR((value % 3) * 0.33f,((value / 3) % 3) * 0.33f,((value / 9) % 3) * 0.33f,1);
}

Fixed version (ground truth):
@Override public final int getDebugColorAt(int x,int y){
  int value=partitionsGrid.getRealPartitionIdAt(x,y);
  return Color.getABGR((value % 3) * 0.33f,((value / 3) % 3) * 0.33f,((value / 9) % 3) * 0.33f,1);
}
Program: 56328
Project: 56328
Buggy source:
@Override public final void setDebugColor(final short x,final short y,Color color){
  landscapeGrid.setDebugColor(x,y,color.getARGB());
}

Fixed version (ground truth):
@Override public void setDebugColor(short x,short y,Color color){
  landscapeGrid.setDebugColor(x,y,color.getARGB());
}
Program: 56329
Project: 56329
Buggy source:
public FlagsGrid(final short width,final short height){
  this.width=width;
  this.blockedGrid=new BitSet(width * height);
  this.protectedGrid=new BitSet(width * height);
  this.markedGrid=new BitSet(width * height);
  this.bordersGrid=new BitSet(width * height);
}

Fixed version (ground truth):
public FlagsGrid(final short width,final short height){
  this.width=width;
  this.blockedGrid=new BitSet(width * height);
  this.protectedGrid=new BitSet(width * height);
  this.markedGrid=new BitSet(width * height);
  this.bordersGrid=new BitSet(width * height);
  initAdditional();
}
Program: 56330
Project: 56330
Buggy source:
public Building getBuildingOn(short x,short y){
  return buildingsGrid[x + y * width];
}

Fixed version (ground truth):
public Building getBuildingOn(int x,int y){
  return buildingsGrid[x + y * width];
}
Program: 56331
Project: 56331
Buggy source:
@Override public boolean contains(int x,int y){
  return grid.partitionRepresentative[grid.partitions[x + y * width]] == partition;
}

Fixed version (ground truth):
@Override public boolean contains(int x,int y){
  return grid.partitionRepresentatives[grid.partitions[x + y * width]] == partition;
}
Program: 56332
Project: 56332
Buggy source:
/** 
 * Tests if the given positions (that need to lie on the border of the given partition) are connected by the given partition.
 * @param pos1 The first position.
 * @param pos2 The second position.
 * @param partition The partition of both positions.
 * @return true if both positions are connected by the given partition.<br>false if the positions are not connected.
 */
public static boolean isPartitionNotDivided(final PartitionsGrid grid,final ShortPoint2D pos1,final ShortPoint2D pos2,final short partition){
  final short width=grid.width;
  final short pos2X=pos2.x;
  final short pos2Y=pos2.y;
  boolean pos2NotOnBorder=BorderTraversingAlgorithm.traverseBorder(new IContainingProvider(){
    @Override public boolean contains(    int x,    int y){
      return grid.partitionRepresentative[grid.partitions[x + y * width]] == partition;
    }
  }
,pos1,new ITraversingVisitor(){
    @Override public boolean visit(    int x,    int y){
      return pos2X != x || pos2Y != y;
    }
  }
,false);
  return !pos2NotOnBorder;
}

Fixed version (ground truth):
/** 
 * Tests if the given positions (that need to lie on the border of the given partition) are connected by the given partition.
 * @param pos1 The first position.
 * @param pos2 The second position.
 * @param partition The partition of both positions.
 * @return true if both positions are connected by the given partition.<br>false if the positions are not connected.
 */
public static boolean isPartitionNotDivided(final PartitionsGrid grid,final ShortPoint2D pos1,final ShortPoint2D pos2,final short partition){
  final short width=grid.width;
  final short pos2X=pos2.x;
  final short pos2Y=pos2.y;
  boolean pos2NotOnBorder=BorderTraversingAlgorithm.traverseBorder(new IContainingProvider(){
    @Override public boolean contains(    int x,    int y){
      return grid.partitionRepresentatives[grid.partitions[x + y * width]] == partition;
    }
  }
,pos1,new ITraversingVisitor(){
    @Override public boolean visit(    int x,    int y){
      return pos2X != x || pos2Y != y;
    }
  }
,false);
  return !pos2NotOnBorder;
}
Program: 56333
Project: 56333
Buggy source:
public static void main(String args[]){
  JOGLPanel content=new JOGLPanel(new SoundPlayer(){
    @Override public void playSound(    int sound,    float lvolume,    float rvolume){
    }
    @Override public void setSoundDataRetriever(    ISoundDataRetriever soundDataRetriever){
    }
  }
);
  ResourceManager.setProvider(new SwingResourceProvider());
  map=new Map();
  MapInterfaceConnector connector=content.showGameMap(map,null);
  connector.addListener(new IMapInterfaceListener(){
    @Override public void action(    Action action){
      if (action.getActionType() == EActionType.SELECT_POINT) {
        System.out.println("String_Node_Str" + ((SelectAction)action).getPosition());
      }
    }
  }
);
  JFrame jsettlersWnd=new JFrame("String_Node_Str");
  AreaContainer panel=new AreaContainer(content.getArea());
  panel.setPreferredSize(new Dimension(640,480));
  jsettlersWnd.add(panel);
  panel.requestFocusInWindow();
  jsettlersWnd.pack();
  jsettlersWnd.setSize(1200,800);
  jsettlersWnd.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  jsettlersWnd.setVisible(true);
  jsettlersWnd.setLocationRelativeTo(null);
  thread=new LandmarksCorrectingThread(map);
  test1();
  test2();
}

Fixed version (ground truth):
public static void main(String args[]){
  JOGLPanel content=new JOGLPanel(new SoundPlayer(){
    @Override public void playSound(    int sound,    float lvolume,    float rvolume){
    }
    @Override public void setSoundDataRetriever(    ISoundDataRetriever soundDataRetriever){
    }
  }
);
  ResourceManager.setProvider(new SwingResourceProvider());
  map=new Map();
  MapInterfaceConnector connector=content.showGameMap(map,null);
  connector.addListener(new IMapInterfaceListener(){
    @Override public void action(    Action action){
      if (action.getActionType() == EActionType.SELECT_POINT) {
        System.out.println("String_Node_Str" + ((PointAction)action).getPosition());
      }
    }
  }
);
  JFrame jsettlersWnd=new JFrame("String_Node_Str");
  AreaContainer panel=new AreaContainer(content.getArea());
  panel.setPreferredSize(new Dimension(640,480));
  jsettlersWnd.add(panel);
  panel.requestFocusInWindow();
  jsettlersWnd.pack();
  jsettlersWnd.setSize(1200,800);
  jsettlersWnd.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  jsettlersWnd.setVisible(true);
  jsettlersWnd.setLocationRelativeTo(null);
  thread=new LandmarksCorrectingThread(map);
  test1();
  test2();
}
Program: 56334
Project: 56334
Buggy source:
@Override public void action(Action action){
  if (action.getActionType() == EActionType.SELECT_POINT) {
    System.out.println("String_Node_Str" + ((SelectAction)action).getPosition());
  }
}

Fixed version (ground truth):
@Override public void action(Action action){
  if (action.getActionType() == EActionType.SELECT_POINT) {
    System.out.println("String_Node_Str" + ((PointAction)action).getPosition());
  }
}
Program: 56335
Project: 56335
Buggy source:
@Override public void action(Action action){
switch (action.getActionType()) {
case MOVE_TO:
    movable.moveTo(((MoveToAction)action).getPosition());
  break;
case SPEED_FASTER:
NetworkTimer.multiplyGameSpeed(1.2f);
break;
case SPEED_SLOWER:
NetworkTimer.multiplyGameSpeed(1 / 1.2f);
break;
case FAST_FORWARD:
NetworkTimer.get().fastForward();
break;
default :
break;
}
}

Fixed version (ground truth):
@Override public void action(Action action){
switch (action.getActionType()) {
case MOVE_TO:
    movable.moveTo(((PointAction)action).getPosition());
  break;
case SPEED_FASTER:
NetworkTimer.multiplyGameSpeed(1.2f);
break;
case SPEED_SLOWER:
NetworkTimer.multiplyGameSpeed(1 / 1.2f);
break;
case FAST_FORWARD:
NetworkTimer.get().fastForward();
break;
default :
break;
}
}
Program: 56337
Project: 56337
Buggy source:
@Test public void testCompareOldAndNew() throws MapLoadException {
  MainGrid grid=new MapLoader(new File(MapList.getDefaultFolder(),"String_Node_Str")).getMainGrid();
  MainGridDataAccessor gridAccessor=new MainGridDataAccessor(grid);
  short width=gridAccessor.getWidth();
  short height=gridAccessor.getHeight();
  BitSet notBlockingSet=new BitSet(width * height);
  LandscapeGrid landscapeGrid=gridAccessor.getLandscapeGrid();
  for (short y=0; y < height; y++) {
    for (short x=0; x < width; x++) {
      notBlockingSet.set(x + y * width,!landscapeGrid.getLandscapeTypeAt(x,y).isBlocking);
    }
  }
  PartitionCalculatorAlgorithm partitioner=new PartitionCalculatorAlgorithm(0,0,width,height,notBlockingSet,IBlockingProvider.DEFAULT_PROVIDER);
  partitioner.calculatePartitions();
  System.out.println("String_Node_Str" + partitioner.getNumberOfPartitions());
  for (short y=0; y < height; y++) {
    for (short x=0; x < width; x++) {
      assertEquals(gridAccessor.getLandscapeGrid().getBlockedPartitionAt(x,y),partitioner.getPartitionAt(x,y));
    }
  }
}

Fixed version (ground truth):
@Test public void testCompareOldAndNew() throws MapLoadException {
  MainGrid grid=new MapLoader(new File(MapList.getDefaultFolder(),"String_Node_Str")).getMainGrid();
  MainGridDataAccessor gridAccessor=new MainGridDataAccessor(grid);
  short width=gridAccessor.getWidth();
  short height=gridAccessor.getHeight();
  BitSet notBlockingSet=new BitSet(width * height);
  LandscapeGrid landscapeGrid=gridAccessor.getLandscapeGrid();
  for (short y=0; y < height; y++) {
    for (short x=0; x < width; x++) {
      notBlockingSet.set(x + y * width,!landscapeGrid.getLandscapeTypeAt(x,y).isBlocking);
    }
  }
  PartitionCalculatorAlgorithm partitioner=new PartitionCalculatorAlgorithm(0,0,width,height,notBlockingSet,IBlockingProvider.DEFAULT_IMPLEMENTATION);
  partitioner.calculatePartitions();
  System.out.println("String_Node_Str" + partitioner.getNumberOfPartitions());
  for (short y=0; y < height; y++) {
    for (short x=0; x < width; x++) {
      assertEquals(gridAccessor.getLandscapeGrid().getBlockedPartitionAt(x,y),partitioner.getPartitionAt(x,y));
    }
  }
}
Program: 56338
Project: 56338
Buggy source:
public static void main(String[] args) throws MapLoadException, InterruptedException {
  MainGrid grid=new MapLoader(new File(MapList.getDefaultFolder(),"String_Node_Str")).getMainGrid();
  MainGridDataAccessor gridAccessor=new MainGridDataAccessor(grid);
  short width=gridAccessor.getWidth();
  short height=gridAccessor.getHeight();
  BitSet notBlockingSet=new BitSet(width * height);
  LandscapeGrid landscapeGrid=gridAccessor.getLandscapeGrid();
  for (short y=0; y < height; y++) {
    for (short x=0; x < width; x++) {
      notBlockingSet.set(x + y * width,!landscapeGrid.getLandscapeTypeAt(x,y).isBlocking);
    }
  }
  Thread.sleep(500);
  MilliStopWatch watch=new MilliStopWatch();
  PartitionCalculatorAlgorithm partitioner=new PartitionCalculatorAlgorithm(0,0,width,height,notBlockingSet,IBlockingProvider.DEFAULT_PROVIDER);
  partitioner.calculatePartitions();
  System.out.println("String_Node_Str" + partitioner.getNumberOfPartitions());
  watch.stop("String_Node_Str");
  System.exit(0);
}

Fixed version (ground truth):
public static void main(String[] args) throws MapLoadException, InterruptedException {
  MainGrid grid=new MapLoader(new File(MapList.getDefaultFolder(),"String_Node_Str")).getMainGrid();
  MainGridDataAccessor gridAccessor=new MainGridDataAccessor(grid);
  short width=gridAccessor.getWidth();
  short height=gridAccessor.getHeight();
  BitSet notBlockingSet=new BitSet(width * height);
  LandscapeGrid landscapeGrid=gridAccessor.getLandscapeGrid();
  for (short y=0; y < height; y++) {
    for (short x=0; x < width; x++) {
      notBlockingSet.set(x + y * width,!landscapeGrid.getLandscapeTypeAt(x,y).isBlocking);
    }
  }
  Thread.sleep(500);
  MilliStopWatch watch=new MilliStopWatch();
  PartitionCalculatorAlgorithm partitioner=new PartitionCalculatorAlgorithm(0,0,width,height,notBlockingSet,IBlockingProvider.DEFAULT_IMPLEMENTATION);
  partitioner.calculatePartitions();
  System.out.println("String_Node_Str" + partitioner.getNumberOfPartitions());
  watch.stop("String_Node_Str");
  System.exit(0);
}
Program: 56339
Project: 56339
Buggy source:
private PartitionsGridTestingWnd(){
  this.grid=new PartitionsGrid(WIDTH,HEIGHT,(byte)10,IBlockingProvider.DEFAULT_PROVIDER);
}

Fixed version (ground truth):
private PartitionsGridTestingWnd(){
  this.grid=new PartitionsGrid(WIDTH,HEIGHT,(byte)10,IPartitionsGridBlockingProvider.DEFAULT_IMPLEMENTATION);
}
Program: 56340
Project: 56340
Buggy source:
private void changePlayerOfTower(int x,int y,int newPlayer){
  ShortPoint2D pos=new ShortPoint2D(x,y);
  grid.changePlayerOfTower(pos,(byte)newPlayer,new FreeMapArea(pos,EBuildingType.TOWER.getProtectedTiles()));
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") private void changePlayerOfTower(int x,int y,int newPlayer){
  ShortPoint2D pos=new ShortPoint2D(x,y);
  grid.changePlayerOfTower(pos,(byte)newPlayer,new FreeMapArea(pos,EBuildingType.TOWER.getProtectedTiles()));
}
Program: 56341
Project: 56341
Buggy source:
@Override public void run(){
  while (!canceled) {
    try {
synchronized (this) {
        while (buildingType == null) {
          this.wait();
        }
      }
      while (buildingType != null && !canceled) {
        if (!NetworkTimer.isPausing()) {
          StopWatch watch=new MilliStopWatch();
          watch.start();
          calculateConstructMarks();
          watch.stop("String_Node_Str");
        }
synchronized (this) {
          wait(AlgorithmConstants.CONSTRUCT_MARKS_MAX_REFRESH_TIME);
        }
      }
      removeConstructionMarks(lastArea);
      lastArea=null;
    }
 catch (    InterruptedException e) {
    }
catch (    Throwable e) {
      e.printStackTrace();
    }
  }
}

Fixed version (ground truth):
@Override public void run(){
  while (!canceled) {
    try {
synchronized (this) {
        while (buildingType == null) {
          this.wait();
        }
      }
      while (buildingType != null && !canceled) {
        if (!NetworkTimer.isPausing()) {
          StopWatch watch=new MilliStopWatch();
          watch.start();
          calculateConstructMarks();
          watch.stop("String_Node_Str");
        }
synchronized (this) {
          wait(AlgorithmConstants.CONSTRUCT_MARKS_MAX_REFRESH_TIME);
        }
      }
      removeConstructionMarks(lastArea);
      lastArea=null;
    }
 catch (    InterruptedException e) {
    }
catch (    Throwable t) {
      t.printStackTrace();
    }
  }
}
Program: 56342
Project: 56342
Buggy source:
/** 
 * Normalizes the partitions and compacts them.
 */
private void normalizePartitions(){
  short[] compacted=new short[partitions.length + 1];
  compacted[NO_PARTITION]=NO_PARTITION;
  compacted[BLOCKED_PARTITION]=BLOCKED_PARTITION;
  short compactedCount=NUMBER_OF_RESERVED_PARTITIONS;
  for (short i=NUMBER_OF_RESERVED_PARTITIONS; i < nextFreePartition; i++) {
    short representative=i;
    short nextRep;
    while (representative != (nextRep=partitions[representative])) {
      representative=nextRep;
    }
    if (compacted[representative] == 0) {
      compacted[representative]=compactedCount++;
      partitionBorderPositions[compactedCount]=partitionBorderPositions[representative];
    }
    partitions[i]=representative;
    compacted[i]=compacted[representative];
  }
  partitions=compacted;
  neededPartitions=(short)(compactedCount - 1);
}

Fixed version (ground truth):
/** 
 * Normalizes the partitions and compacts them.
 */
private void normalizePartitions(){
  short[] compacted=new short[partitions.length + 1];
  compacted[NO_PARTITION]=NO_PARTITION;
  compacted[BLOCKED_PARTITION]=BLOCKED_PARTITION;
  short compactedCount=NUMBER_OF_RESERVED_PARTITIONS;
  for (short i=NUMBER_OF_RESERVED_PARTITIONS; i < nextFreePartition; i++) {
    short representative=i;
    short nextRep;
    while (representative != (nextRep=partitions[representative])) {
      representative=nextRep;
    }
    if (compacted[representative] == 0) {
      compacted[representative]=compactedCount++;
      partitionBorderPositions[compactedCount]=partitionBorderPositions[representative];
    }
    partitions[i]=representative;
    compacted[i]=compacted[representative];
  }
  partitions=compacted;
  neededPartitions=compactedCount;
}
Program: 56343
Project: 56343
Buggy source:
public static void dropAllBuildings(){
  allBuildings.clear();
  OccupyingBuilding.dropAllBuildings();
}

Fixed version (ground truth):
public static void dropAllBuildings(){
  allBuildings.clear();
}
Program: 56344
Project: 56344
Buggy source:
@Override public void receiveHit(float strength,ShortPoint2D attackerPos){
  if (doorHealth > 0) {
    doorHealth-=strength / Constants.DOOR_HIT_RESISTENCY_FACTOR;
    if (doorHealth <= 0) {
      doorHealth=0;
      inFight=true;
      OccupyingBuilding.this.getGrid().getMapObjectsManager().addSelfDeletingMapObject(getPos(),EMapObjectType.GHOST,Constants.GHOST_PLAY_DURATION,getPlayer());
      pollNewDefender();
    }
  }
 else   if (currDefender != null) {
    IAttackableMovable movable=currDefender.getSoldier().getMovable();
    movable.receiveHit(strength,attackerPos);
    if (movable.getHealth() <= 0) {
      if (occupiers.isEmpty()) {
        currDefender=null;
        changePlayerTo(attackerPos);
      }
 else {
        emptyPlaces.add(currDefender.place);
        searchedSoldiers.add(getSearchType(currDefender.getSoldier().getMovableType()));
        pollNewDefender();
      }
    }
  }
}

Fixed version (ground truth):
@Override public void receiveHit(float strength,ShortPoint2D attackerPos){
  if (getGrid().getMovable(attackerPos).getPlayer() == getPlayer()) {
    return;
  }
  if (doorHealth > 0) {
    doorHealth-=strength / Constants.DOOR_HIT_RESISTENCY_FACTOR;
    if (doorHealth <= 0) {
      doorHealth=0;
      inFight=true;
      OccupyingBuilding.this.getGrid().getMapObjectsManager().addSelfDeletingMapObject(getPos(),EMapObjectType.GHOST,Constants.GHOST_PLAY_DURATION,getPlayer());
      pollNewDefender();
    }
  }
 else   if (currDefender != null) {
    IAttackableMovable movable=currDefender.getSoldier().getMovable();
    movable.receiveHit(strength,attackerPos);
    if (movable.getHealth() <= 0) {
      if (occupiers.isEmpty()) {
        currDefender=null;
        changePlayerTo(attackerPos);
      }
 else {
        emptyPlaces.add(currDefender.place);
        searchedSoldiers.add(getSearchType(currDefender.getSoldier().getMovableType()));
        pollNewDefender();
      }
    }
  }
}
Program: 56345
Project: 56345
Buggy source:
@Override protected final void killedEvent(){
  setSelected(false);
  if (occupiedArea) {
    freeArea();
    int idx=0;
    FreeMapArea buildingArea=super.getBuildingArea();
    for (    TowerOccupyer curr : occupiers) {
      addInformableMapObject(curr,false);
      curr.getSoldier().leaveOccupyableBuilding(buildingArea.get(idx));
      idx++;
    }
    occupiers.clear();
  }
  allOccupyingBuildings.remove(this);
  setAttackableTowerObject(false);
}

Fixed version (ground truth):
@Override protected final void killedEvent(){
  setSelected(false);
  if (occupiedArea) {
    freeArea();
    int idx=0;
    FreeMapArea buildingArea=super.getBuildingArea();
    for (    TowerOccupyer curr : occupiers) {
      addInformableMapObject(curr,false);
      curr.getSoldier().leaveOccupyableBuilding(buildingArea.get(idx));
      idx++;
    }
    occupiers.clear();
  }
  setAttackableTowerObject(false);
}
Program: 56346
Project: 56346
Buggy source:
@Override public void towerDefended(IBuildingOccupyableMovable soldier){
  inFight=false;
  occupiers.add(new TowerOccupyer(attackableTowerObject.currDefender.place,soldier));
  attackableTowerObject.currDefender=null;
}

Fixed version (ground truth):
@Override public void towerDefended(IBuildingOccupyableMovable soldier){
  inFight=false;
  if (attackableTowerObject.currDefender == null) {
    System.out.println();
  }
  occupiers.add(new TowerOccupyer(attackableTowerObject.currDefender.place,soldier));
  attackableTowerObject.currDefender=null;
}
Program: 56347
Project: 56347
Buggy source:
public OccupyingBuilding(EBuildingType type,Player player){
  super(type,player);
  this.occupiers=new LinkedList<TowerOccupyer>();
  initSoldierRequests();
  allOccupyingBuildings.add(this);
  delayCtr=(byte)RandomSingleton.getInt(0,3);
}

Fixed version (ground truth):
public OccupyingBuilding(EBuildingType type,Player player){
  super(type,player);
  this.occupiers=new LinkedList<TowerOccupyer>();
  initSoldierRequests();
  delayCtr=(byte)RandomSingleton.getInt(0,3);
}
Program: 56348
Project: 56348
Buggy source:
@Override public final int getDebugColorAt(int x,int y){
  return flagsGrid.isMarked(x,y) ? Color.ORANGE.getARGB() : (objectsGrid.getMapObjectAt(x,y,EMapObjectType.INFORMABLE_MAP_OBJECT) != null ? Color.GREEN.getARGB() : (objectsGrid.getMapObjectAt(x,y,EMapObjectType.ATTACKABLE_TOWER) != null ? Color.RED.getARGB() : (flagsGrid.isBlocked(x,y) ? Color.BLACK.getARGB() : (flagsGrid.isProtected(x,y) ? Color.BLUE.getARGB() : 0))));
}

Fixed version (ground truth):
@Override public final int getDebugColorAt(int x,int y){
  int value=partitionsGrid.getPartitionIdAt(x,y) + 1;
  return Color.getARGB((value % 3) * 0.33f,((value / 3) % 3) * 0.33f,((value / 9) % 3) * 0.33f,1);
}
Program: 56349
Project: 56349
Buggy source:
private static void loadSingleLib(String file) throws IOException {
  File temporary=File.createTempFile("String_Node_Str" + file,"String_Node_Str" + getExtension());
  FileOutputStream out=new FileOutputStream(temporary);
  String filename=getLibDir() + System.mapLibraryName(file);
  InputStream in=JoglLoader.class.getResourceAsStream(filename);
  if (in == null) {
    throw new IOException("String_Node_Str");
  }
  int n;
  byte buffer[]=new byte[4096];
  while ((n=in.read(buffer)) != -1) {
    out.write(buffer,0,n);
  }
  in.close();
  out.close();
  System.load(temporary.getAbsolutePath());
  temporary.deleteOnExit();
}

Fixed version (ground truth):
private static void loadSingleLib(String file) throws IOException {
  File temporary=File.createTempFile("String_Node_Str" + file,"String_Node_Str" + getExtension());
  String filename=getLibDir() + System.mapLibraryName(file);
  InputStream in=JoglLoader.class.getResourceAsStream(filename);
  if (in == null) {
    throw new IOException("String_Node_Str");
  }
  FileOutputStream out=new FileOutputStream(temporary);
  int n;
  byte buffer[]=new byte[4096];
  while ((n=in.read(buffer)) != -1) {
    out.write(buffer,0,n);
  }
  in.close();
  out.close();
  System.load(temporary.getAbsolutePath());
  temporary.deleteOnExit();
}
Program: 56350
Project: 56350
Buggy source:
private void select(ShortPoint2D pos){
  if (grid.isInBounds(pos)) {
    short x=pos.x;
    short y=pos.y;
    IGuiMovable m1=grid.getMovable((short)(x + 1),(short)(y + 1));
    IGuiMovable m2=grid.getMovable((x),(short)(y + 1));
    IGuiMovable m3=grid.getMovable(x,y);
    IGuiMovable m4=grid.getMovable((short)(x + 1),(short)(y + 2));
    if (m1 != null) {
      setSelection(new SelectionSet(m1));
    }
 else     if (m2 != null) {
      setSelection(new SelectionSet(m2));
    }
 else     if (m3 != null) {
      setSelection(new SelectionSet(m3));
    }
 else     if (m4 != null) {
      setSelection(new SelectionSet(m4));
    }
 else {
      IBuilding building=getBuildingAround(pos);
      if (building != null) {
        setSelection(new SelectionSet(building));
      }
 else {
        setSelection(new SelectionSet());
      }
    }
  }
}

Fixed version (ground truth):
private void select(ShortPoint2D pos){
  if (grid.isInBounds(pos)) {
    short x=pos.x;
    short y=pos.y;
    IGuiMovable m1=grid.getMovable(x,y);
    IGuiMovable m3=grid.getMovable((short)(x + 1),(short)(y + 1));
    IGuiMovable m2=grid.getMovable((x),(short)(y + 1));
    IGuiMovable m4=grid.getMovable((short)(x + 1),(short)(y + 2));
    if (m1 != null) {
      setSelection(new SelectionSet(m1));
      System.out.println("String_Node_Str" + pos);
    }
 else     if (m2 != null) {
      setSelection(new SelectionSet(m2));
    }
 else     if (m3 != null) {
      setSelection(new SelectionSet(m3));
    }
 else     if (m4 != null) {
      setSelection(new SelectionSet(m4));
    }
 else {
      IBuilding building=getBuildingAround(pos);
      if (building != null) {
        setSelection(new SelectionSet(building));
      }
 else {
        setSelection(new SelectionSet());
      }
    }
  }
}
Program: 56351
Project: 56351
Buggy source:
private void handleSelectPointAction(PointAction action){
  ShortPoint2D pos=action.getPosition();
  System.out.println("String_Node_Str" + pos.x + "String_Node_Str"+ pos.y+ "String_Node_Str");
  if (activeAction == null) {
    select(pos);
  }
 else {
switch (activeAction.getActionType()) {
case BUILD:
      EBuildingType type=previewBuilding;
    ShortPoint2D pos2=grid.getConstructablePositionAround(pos,type);
  if (pos2 != null) {
    cancelBuildingCreation();
    scheduleTask(new GeneralGuiTask(EGuiAction.BUILD,pos2,type));
    break;
  }
 else {
    return;
  }
default :
break;
}
setActiveAction(null);
}
}

Fixed version (ground truth):
private void handleSelectPointAction(PointAction action){
  ShortPoint2D pos=action.getPosition();
  grid.postionClicked(pos.x,pos.y);
  if (activeAction == null) {
    select(pos);
  }
 else {
switch (activeAction.getActionType()) {
case BUILD:
      EBuildingType type=previewBuilding;
    ShortPoint2D pos2=grid.getConstructablePositionAround(pos,type);
  if (pos2 != null) {
    cancelBuildingCreation();
    scheduleTask(new GeneralGuiTask(EGuiAction.BUILD,pos2,type));
    break;
  }
 else {
    return;
  }
default :
break;
}
setActiveAction(null);
}
}
Program: 56352
Project: 56352
Buggy source:
private final void appearAt(IBuildingsGrid grid,ShortPoint2D pos){
  this.state=STATE_CONSTRUCTED;
  positionAt(grid,pos);
  if (this.pos != null) {
    grid.setBlocked(getBuildingArea(),true);
    finishConstruction();
  }
  appearedEvent();
}

Fixed version (ground truth):
private final void appearAt(IBuildingsGrid grid,ShortPoint2D pos){
  this.state=STATE_CONSTRUCTED;
  boolean itWorked=positionAt(grid,pos);
  if (itWorked) {
    grid.setBlocked(getBuildingArea(),true);
    finishConstruction();
    appearedEvent();
  }
 else {
    kill();
  }
}