nus-yam/ex-repair huggingface dataset:
Program: 96853
Project: 96853
Buggy source:
public void parse(Node node){
  Element element=(Element)node;
  id=Integer.parseInt(element.getAttribute("String_Node_Str"));
  NodeList nodes=element.getElementsByTagName("String_Node_Str");
  if (nodes.getLength() > 0)   properties.parse(nodes.item(0));
  nodes=element.getElementsByTagName("String_Node_Str");
  if (nodes.getLength() > 0) {
    animated=true;
    Node frameNode=nodes.item(0).getFirstChild();
    while (frameNode != null) {
      Element frame=(Element)frameNode;
      int tileID=Integer.parseInt(frame.getAttribute("String_Node_Str"));
      int duration=Integer.parseInt(frame.getAttribute("String_Node_Str"));
      TmxAnimationFrame animation=new TmxAnimationFrame(tileID,totalDuration);
      frames.add(animation);
      totalDuration+=duration;
      frameNode=frameNode.getNextSibling();
    }
  }
}

Fixed version (ground truth):
public void parse(Node node){
  Element element=(Element)node;
  id=Integer.parseInt(element.getAttribute("String_Node_Str"));
  NodeList nodes=element.getElementsByTagName("String_Node_Str");
  if (nodes.getLength() > 0)   properties.parse(nodes.item(0));
  nodes=element.getElementsByTagName("String_Node_Str");
  if (nodes.getLength() > 0) {
    animated=true;
    NodeList tiles=((Element)nodes.item(0)).getElementsByTagName("String_Node_Str");
    for (int i=0; i < tiles.getLength(); i++) {
      Element frame=(Element)tiles.item(i);
      int tileID=Integer.parseInt(frame.getAttribute("String_Node_Str"));
      int duration=Integer.parseInt(frame.getAttribute("String_Node_Str"));
      TmxAnimationFrame animation=new TmxAnimationFrame(tileID,duration);
      frames.add(animation);
      totalDuration+=duration;
    }
  }
}
Program: 96854
Project: 96854
Buggy source:
private ResourceLoader(){
  textures=new HashMap<>();
  fonts=new HashMap<>();
  sounds=new HashMap<>();
  models=new HashMap<>();
  texturesToLoad=new HashMap<>();
  fontsToLoad=new HashMap<>();
  soundsToLoad=new HashMap<>();
  modelsToLoad=new HashMap<>();
  numLoaded=0;
  setLogo("String_Node_Str");
  setRenderProgressCallback(this::defaultRenderProgressCallback);
}

Fixed version (ground truth):
private ResourceLoader(){
  textures=new HashMap<>();
  fonts=new HashMap<>();
  sounds=new HashMap<>();
  models=new HashMap<>();
  texturesToLoad=new HashMap<>();
  fontsToLoad=new HashMap<>();
  soundsToLoad=new HashMap<>();
  modelsToLoad=new HashMap<>();
  numLoaded=0;
  setRenderProgressCallback(this::defaultRenderProgressCallback);
}
Program: 96855
Project: 96855
Buggy source:
public void startLoading(){
  smoothedProgress=0;
  numLoaded=0;
  fileInfo="String_Node_Str";
  Display.setHints();
  loaderWindow=new Window(Display.getWindow());
  Thread loadingThread=new Thread(this::loadResources);
  loadingThread.start();
  float progress;
  while ((progress=updateProgress()) != 100) {
    SilenceEngine.graphics.beginFrame();
    GL3Context.viewport(0,0,Display.getWidth(),Display.getHeight());
    SilenceEngine.graphics.getGraphics2D().getCamera().initProjection(Display.getWidth(),Display.getHeight());
    renderProgressCallback.invoke(SilenceEngine.graphics.getBatcher(),progress,fileInfo);
    SilenceEngine.graphics.endFrame();
    sleep(1000 / Game.getTargetUPS());
  }
  loaderWindow.destroy();
  Window.setDefaultHints();
}

Fixed version (ground truth):
public void startLoading(){
  smoothedProgress=0;
  numLoaded=0;
  fileInfo="String_Node_Str";
  if (logo == null)   setLogo("String_Node_Str");
  Display.setHints();
  loaderWindow=new Window(Display.getWindow());
  Thread loadingThread=new Thread(this::loadResources);
  loadingThread.start();
  float progress;
  while ((progress=updateProgress()) != 100) {
    SilenceEngine.graphics.beginFrame();
    GL3Context.viewport(0,0,Display.getWidth(),Display.getHeight());
    SilenceEngine.graphics.getGraphics2D().getCamera().initProjection(Display.getWidth(),Display.getHeight());
    renderProgressCallback.invoke(SilenceEngine.graphics.getBatcher(),progress,fileInfo);
    SilenceEngine.graphics.endFrame();
    sleep(1000 / Game.getTargetUPS());
  }
  loaderWindow.destroy();
  Window.setDefaultHints();
}
Program: 96856
Project: 96856
Buggy source:
public static Texture fromColor(Color c,int width,int height){
  ByteBuffer buffer=BufferUtils.createByteBuffer(width * height * 4);
  for (int i=0; i < height; i++) {
    for (int j=0; j < width; j++) {
      buffer.put((byte)(c.getR() * 255f)).put((byte)(c.getG() * 255f)).put((byte)(c.getB() * 255f)).put((byte)(c.getA() * 255f));
    }
  }
  buffer.flip();
  return fromByteBuffer(buffer,width,height);
}

Fixed version (ground truth):
public static Texture fromColor(Color c,int width,int height){
  ByteBuffer buffer=BufferUtils.createByteBuffer(width * height * 4);
  for (int i=0; i < height; i++) {
    for (int j=0; j < width; j++) {
      buffer.put((byte)(c.getR() * 255f)).put((byte)(c.getG() * 255f)).put((byte)(c.getB() * 255f)).put((byte)(c.getA() * 255f));
    }
  }
  buffer.flip();
  return fromByteBuffer(buffer,width,height,4);
}
Program: 96857
Project: 96857
Buggy source:
public static Texture fromInputStream(InputStream stream){
  ByteBuffer imageBuffer=FileUtils.readToByteBuffer(stream);
  IntBuffer width=BufferUtils.createIntBuffer(1);
  IntBuffer height=BufferUtils.createIntBuffer(1);
  IntBuffer components=BufferUtils.createIntBuffer(1);
  if (stbi_info_from_memory(imageBuffer,width,height,components) == NULL)   throw new SilenceException("String_Node_Str" + stbi_failure_reason());
  return fromByteBuffer(stbi_load_from_memory(imageBuffer,width,height,components,0),width.get(),height.get());
}

Fixed version (ground truth):
public static Texture fromInputStream(InputStream stream){
  ByteBuffer imageBuffer=FileUtils.readToByteBuffer(stream);
  IntBuffer width=BufferUtils.createIntBuffer(1);
  IntBuffer height=BufferUtils.createIntBuffer(1);
  IntBuffer components=BufferUtils.createIntBuffer(1);
  ByteBuffer image=stbi_load_from_memory(imageBuffer,width,height,components,0);
  if (image == null)   throw new SilenceException("String_Node_Str" + stbi_failure_reason());
  Texture texture=fromByteBuffer(image,width.get(),height.get(),components.get());
  stbi_image_free(image);
  return texture;
}
Program: 96858
Project: 96858
Buggy source:
public static Texture fromByteBuffer(ByteBuffer buffer,int width,int height){
  Texture texture=new Texture();
  texture.bind();
  texture.setFilter(GL_LINEAR_MIPMAP_LINEAR,GL_LINEAR);
  texture.image2d(buffer,GL_UNSIGNED_BYTE,GL_RGBA,width,height,GL_RGBA8);
  texture.generateMipMaps();
  return texture;
}

Fixed version (ground truth):
public static Texture fromByteBuffer(ByteBuffer buffer,int width,int height,int components){
  Texture texture=new Texture();
  texture.bind();
  texture.setFilter(GL_LINEAR_MIPMAP_LINEAR,GL_LINEAR);
  texture.image2d(buffer,GL_UNSIGNED_BYTE,components == 4 ? GL_RGBA : GL_RGB,width,height,GL_RGBA8);
  texture.generateMipMaps();
  return texture;
}
Program: 96859
Project: 96859
Buggy source:
public static Texture fromBufferedImage(BufferedImage img){
  ByteBuffer buffer=BufferUtils.createByteBuffer(img.getWidth() * img.getHeight() * 4);
  for (int y=0; y < img.getHeight(); y++) {
    for (int x=0; x < img.getWidth(); x++) {
      int pixel=img.getRGB(x,y);
      buffer.put((byte)((pixel >> 16) & 0xFF));
      buffer.put((byte)((pixel >> 8) & 0xFF));
      buffer.put((byte)(pixel & 0xFF));
      buffer.put((byte)((pixel >> 24) & 0xFF));
    }
  }
  buffer.rewind();
  return fromByteBuffer(buffer,img.getWidth(),img.getHeight());
}

Fixed version (ground truth):
public static Texture fromBufferedImage(BufferedImage img){
  ByteBuffer buffer=BufferUtils.createByteBuffer(img.getWidth() * img.getHeight() * 4);
  for (int y=0; y < img.getHeight(); y++) {
    for (int x=0; x < img.getWidth(); x++) {
      int pixel=img.getRGB(x,y);
      buffer.put((byte)((pixel >> 16) & 0xFF));
      buffer.put((byte)((pixel >> 8) & 0xFF));
      buffer.put((byte)(pixel & 0xFF));
      buffer.put((byte)((pixel >> 24) & 0xFF));
    }
  }
  buffer.rewind();
  return fromByteBuffer(buffer,img.getWidth(),img.getHeight(),4);
}
Program: 96860
Project: 96860
Buggy source:
public static ByteBuffer readToByteBuffer(InputStream inputStream){
  ByteArrayOutputStream outputStream=new ByteArrayOutputStream();
  byte[] buffer=new byte[4096];
  int count=0;
  while (count != -1) {
    try {
      count=inputStream.read(buffer,0,buffer.length);
      outputStream.write(buffer,0,buffer.length);
    }
 catch (    IOException e) {
      SilenceException.reThrow(e);
    }
  }
  ByteBuffer byteBuffer=BufferUtils.createByteBuffer(outputStream.size());
  byteBuffer.put(outputStream.toByteArray()).flip();
  return byteBuffer;
}

Fixed version (ground truth):
public static ByteBuffer readToByteBuffer(InputStream inputStream){
  ByteArrayOutputStream outputStream=new ByteArrayOutputStream();
  byte[] buffer=new byte[4096];
  try {
    while (true) {
      int n=inputStream.read(buffer);
      if (n < 0)       break;
      outputStream.write(buffer,0,n);
    }
    inputStream.close();
  }
 catch (  Exception e) {
    SilenceException.reThrow(e);
  }
  byte[] bytes=outputStream.toByteArray();
  ByteBuffer byteBuffer=BufferUtils.createByteBuffer(bytes.length);
  byteBuffer.put(bytes).flip();
  return byteBuffer;
}
Program: 96861
Project: 96861
Buggy source:
public Animation set(Animation other){
  clearFrames();
  for (int i=0; i < other.frames.size(); i++) {
    addFrame(other.frames.get(i),other.frameLengths.get(i),TimeUtils.getDefaultTimeUnit());
  }
  currentFrame=other.currentFrame;
  setStartCallback(other.startCallback);
  setPauseCallback(other.pauseCallback);
  setResumeCallback(other.resumeCallback);
  setEndCallback(other.endCallback);
  return this;
}

Fixed version (ground truth):
public Animation set(Animation other){
  clearFrames();
  for (int i=0; i < other.frames.size(); i++) {
    addFrame(other.frames.get(i),other.frameLengths.get(i),TimeUtils.getDefaultTimeUnit());
  }
  currentFrame=other.currentFrame;
  time=other.time;
  setStartCallback(other.startCallback);
  setPauseCallback(other.pauseCallback);
  setResumeCallback(other.resumeCallback);
  setEndCallback(other.endCallback);
  return this;
}
Program: 96862
Project: 96862
Buggy source:
public Animation clearFrames(){
  frames.clear();
  frameLengths.clear();
  currentFrame=0;
  return this;
}

Fixed version (ground truth):
public Animation clearFrames(){
  frames.clear();
  frameLengths.clear();
  currentFrame=0;
  time=0;
  return this;
}
Program: 96863
Project: 96863
Buggy source:
public Sprite setAnimation(Animation animation){
  this.animation=animation.copy();
  return this;
}

Fixed version (ground truth):
public Sprite setAnimation(Animation animation){
  this.animation.set(animation);
  return this;
}
Program: 96864
Project: 96864
Buggy source:
public Sprite copy(){
  return new Sprite().set(this);
}

Fixed version (ground truth):
public Sprite copy(){
  return new Sprite(this);
}
Program: 96866
Project: 96866
Buggy source:
/** 
 * Constructs a Entity2D to use a Polygon that can be used to perform collisions.
 * @param sprite  The sprite to use for this entity.
 * @param polygon The collision mask.
 */
public Entity2D(Sprite sprite,Polygon polygon){
  this.sprite=new Sprite(Sprite.EMPTY);
  setSprite(sprite);
  this.polygon=polygon;
  position=new Vector2();
  velocity=new Vector2();
  depth=0;
  id=IDGenerator.generate();
}

Fixed version (ground truth):
/** 
 * Constructs a Entity2D to use a Polygon that can be used to perform collisions.
 * @param sprite  The sprite to use for this entity.
 * @param polygon The collision mask.
 */
public Entity2D(Sprite sprite,Polygon polygon){
  this.sprite=sprite.copy();
  this.polygon=polygon;
  position=new Vector2();
  velocity=new Vector2();
  depth=0;
  id=IDGenerator.generate();
}
Program: 96867
Project: 96867
Buggy source:
public void init(){
  Display.setTitle("String_Node_Str");
  playerTexture=Texture.fromColor(Color.DARK_RED,48,48);
  boxTexture=Texture.fromColor(Color.CORN_FLOWER_BLUE,48,48);
  GL3Context.clearColor(Color.DARK_SLATE_GRAY);
  cam=new OrthoCam().initProjection(Display.getWidth(),Display.getHeight());
  scene=new Scene2D();
  for (int i=0; i < 20; i++) {
    scene.addChild(new Box(new Vector2(48 * i,0)));
    scene.addChild(new Box(new Vector2(0,48 * i)));
    scene.addChild(new Box(new Vector2(48 * i,48 * 19)));
    scene.addChild(new Box(new Vector2(48 * 19,48 * i)));
  }
  scene.addChild(new Player(new Vector2(Display.getWidth() / 2 - 24,Display.getHeight() / 2 - 24)));
  collider=new SceneCollider2D(new DynamicTree2D());
  collider.setScene(scene);
  collider.register(Player.class,Box.class);
  System.out.println(scene.getEntities().size());
}

Fixed version (ground truth):
public void init(){
  Display.setTitle("String_Node_Str");
  playerTexture=Texture.fromColor(Color.DARK_RED,48,48);
  boxTexture=Texture.fromColor(Color.CORN_FLOWER_BLUE,48,48);
  boxSprite=new Sprite(boxTexture);
  playerSprite=new Sprite(playerTexture);
  GL3Context.clearColor(Color.DARK_SLATE_GRAY);
  cam=new OrthoCam().initProjection(Display.getWidth(),Display.getHeight());
  scene=new Scene2D();
  for (int i=0; i < 20; i++) {
    scene.addChild(new Box(new Vector2(48 * i,0)));
    scene.addChild(new Box(new Vector2(0,48 * i)));
    scene.addChild(new Box(new Vector2(48 * i,48 * 19)));
    scene.addChild(new Box(new Vector2(48 * 19,48 * i)));
  }
  scene.addChild(new Player(new Vector2(Display.getWidth() / 2 - 24,Display.getHeight() / 2 - 24)));
  collider=new SceneCollider2D(new DynamicTree2D());
  collider.setScene(scene);
  collider.register(Player.class,Box.class);
  System.out.println(scene.getEntities().size());
}
Program: 96868
Project: 96868
Buggy source:
public Player(Vector2 position){
  super(new Sprite(playerTexture),new Rectangle(48,48));
  setPosition(position);
}

Fixed version (ground truth):
public Player(Vector2 position){
  super(boxSprite,new Rectangle(48,48));
  setPosition(position);
  setSprite(playerSprite);
}
Program: 96869
Project: 96869
Buggy source:
public Box(Vector2 position){
  super(new Sprite(boxTexture),new Rectangle(48,48));
  setPosition(position);
}

Fixed version (ground truth):
public Box(Vector2 position){
  super(boxSprite,new Rectangle(48,48));
  setPosition(position);
}
Program: 96870
Project: 96870
Buggy source:
@Override public void init(){
  Display.setVSync(false);
  camera=new OrthoCam().initProjection(Display.getWidth(),Display.getHeight());
  texture1=Texture.fromResource("String_Node_Str");
  texture2=Texture.fromResource("String_Node_Str");
  sprites=new ArrayList<>();
  positions=new ArrayList<>();
  timer=new GameTimer(0.5,TimeUtils.Unit.SECONDS);
  timer.setCallback(() -> {
    defineSprites();
    timer.start();
  }
);
  timer.start();
}

Fixed version (ground truth):
@Override public void init(){
  Display.setVSync(false);
  camera=new OrthoCam().initProjection(Display.getWidth(),Display.getHeight());
  texture1=Texture.fromResource("String_Node_Str");
  texture2=Texture.fromResource("String_Node_Str");
  sprite1=new Sprite(texture1);
  sprite2=new Sprite(texture2);
  sprites=new ArrayList<>();
  positions=new ArrayList<>();
  for (int i=0; i < 10; i++) {
    sprites.add(new Sprite(i % 2 == 0 ? texture1 : texture2,MathUtils.random_range(1,3),MathUtils.random_range(1,3),MathUtils.random(360)));
    positions.add(new Vector2());
  }
  defineSprites();
  timer=new GameTimer(0.5,TimeUtils.Unit.SECONDS);
  timer.setCallback(() -> {
    defineSprites();
    timer.start();
  }
);
  timer.start();
}
Program: 96871
Project: 96871
Buggy source:
private void defineSprites(){
  sprites.clear();
  positions.clear();
  for (int i=0; i < 10; i++) {
    sprites.add(new Sprite(i % 2 == 0 ? texture1 : texture2,MathUtils.random_range(1,3),MathUtils.random_range(1,3),MathUtils.random(360)));
  }
  for (int y=0; y < 2; y++) {
    for (int x=0; x < 5; x++)     positions.add(new Vector2(Display.getWidth() / 5 * x,Display.getHeight() / 2 * y));
  }
}

Fixed version (ground truth):
private void defineSprites(){
  for (int i=0; i < 10; i++) {
    sprites.get(i).set((MathUtils.random_range(0,2) == 0) ? sprite1 : sprite2).setScaleX(MathUtils.random_range(1,3)).setScaleY(MathUtils.random_range(1,3)).setRotation(MathUtils.random(360));
  }
  int i=0;
  for (int y=0; y < 2; y++) {
    for (int x=0; x < 5; x++, i++)     positions.get(i).set(Display.getWidth() / 5 * x,Display.getHeight() / 2 * y);
  }
}
Program: 96873
Project: 96873
Buggy source:
private void sortMeshes(){
  meshes.sort((m1,m2) -> m1.getMaterial().equals(m2.getMaterial()) ? -1 : 0);
}

Fixed version (ground truth):
private void sortMeshes(){
  indices.sort((i,j) -> meshes.get(i).getMaterial().equals(meshes.get(j).getMaterial()) ? -1 : 1);
}
Program: 96874
Project: 96874
Buggy source:
public ModelBatch(){
  meshes=new ArrayList<>();
  transforms=new ArrayList<>();
}

Fixed version (ground truth):
public ModelBatch(){
  meshes=new ArrayList<>();
  transforms=new ArrayList<>();
  indices=new ArrayList<>();
}
Program: 96875
Project: 96875
Buggy source:
public void addMesh(Mesh mesh,Transform transform){
  meshes.add(mesh);
  transforms.add(transform);
}

Fixed version (ground truth):
public void addMesh(Mesh mesh,Transform transform){
  meshes.add(mesh);
  transforms.add(transform);
  indices.add(meshes.size() - 1);
}
Program: 96876
Project: 96876
Buggy source:
public void begin(Transform transform){
  if (active)   throw new SilenceException("String_Node_Str");
  meshes.clear();
  transforms.clear();
  this.transform=transform;
  active=true;
}

Fixed version (ground truth):
public void begin(Transform transform){
  if (active)   throw new SilenceException("String_Node_Str");
  meshes.clear();
  transforms.clear();
  indices.clear();
  this.transform=transform;
  active=true;
}
Program: 96877
Project: 96877
Buggy source:
/** 
 * Flushes the data collected to the GPU.
 */
public void flush(){
  if (vertexCount == 0)   return;
  fillBuffers();
  unmapBuffers();
  Program.CURRENT.prepareFrame();
  vBuffer.flip();
  cBuffer.flip();
  tBuffer.flip();
  nBuffer.flip();
  vao.bind();
  vao.enableAttributeArray(vertexLocation);
  vao.enableAttributeArray(colorLocation);
  vao.enableAttributeArray(texCoordLocation);
  vao.enableAttributeArray(normalLocation);
  GL3Context.drawArrays(vao,beginMode,0,vertexCount);
  vao.disableAttributeArray(vertexLocation);
  vao.disableAttributeArray(colorLocation);
  vao.disableAttributeArray(texCoordLocation);
  vao.disableAttributeArray(normalLocation);
  GL3Context.bindVertexArray(null);
  vBuffer.clear();
  cBuffer.clear();
  tBuffer.clear();
  nBuffer.clear();
  vertexCount=0;
  colorCount=0;
  texCoordCount=0;
  normalCount=0;
  if (active) {
    mapBuffers();
  }
}

Fixed version (ground truth):
/** 
 * Flushes the data collected to the GPU.
 */
public void flush(){
  if (vertexCount == 0)   return;
  fillBuffers();
  unmapBuffers();
  Program.CURRENT.prepareFrame();
  vBuffer.flip();
  cBuffer.flip();
  tBuffer.flip();
  nBuffer.flip();
  vao.bind();
  vao.enableAttributeArray(vertexLocation);
  vao.enableAttributeArray(colorLocation);
  vao.enableAttributeArray(texCoordLocation);
  vao.enableAttributeArray(normalLocation);
  GL3Context.drawArrays(vao,beginMode,0,vertexCount);
  vao.disableAttributeArray(vertexLocation);
  vao.disableAttributeArray(colorLocation);
  vao.disableAttributeArray(texCoordLocation);
  vao.disableAttributeArray(normalLocation);
  GL3Context.bindVertexArray(null);
  vBuffer.clear();
  cBuffer.clear();
  tBuffer.clear();
  nBuffer.clear();
  vertexCount=0;
  colorCount=0;
  texCoordCount=0;
  normalCount=0;
  mapBuffers();
}
Program: 96878
Project: 96878
Buggy source:
/** 
 * Ends the batcher by flushing all the data to the OpenGL
 */
public void end(){
  if (!active)   throw new IllegalStateException("String_Node_Str");
  active=false;
  flush();
  transform.reset();
}

Fixed version (ground truth):
/** 
 * Ends the batcher by flushing all the data to the OpenGL
 */
public void end(){
  if (!active)   throw new IllegalStateException("String_Node_Str");
  active=false;
  flush();
  unmapBuffers();
  transform.reset();
}
Program: 96879
Project: 96879
Buggy source:
public void addMesh(Mesh mesh,Transform transform){
  if (mesh.getNumberOfVertices() <= 900 || !mesh.prefersStatic()) {
    meshes.add(mesh);
    transforms.add(transform);
    indices.add(meshes.size() - 1);
  }
 else {
    staticMeshes.add(SilenceEngine.graphics.getStaticMesh(mesh));
    staticMeshTransforms.add(transform);
    staticMeshIndices.add(staticMeshes.size() - 1);
  }
}

Fixed version (ground truth):
public void addMesh(Mesh mesh,Transform transform){
  if (mesh.getNumberOfVertices() <= 900 && !mesh.prefersStatic()) {
    meshes.add(mesh);
    transforms.add(transform);
    indices.add(meshes.size() - 1);
  }
 else {
    staticMeshes.add(SilenceEngine.graphics.getStaticMesh(mesh));
    staticMeshTransforms.add(transform);
    staticMeshIndices.add(staticMeshes.size() - 1);
  }
}
Program: 96880
Project: 96880
Buggy source:
private void sortSprites(){
  sprites.sort((s1,s2) -> s1.getTexture().getId() < s2.getTexture().getId() ? 1 : -1);
}

Fixed version (ground truth):
private void sortSprites(){
  indices.sort((i,j) -> sprites.get(i).getTexture().getId() < sprites.get(j).getTexture().getId() ? 1 : -1);
}
Program: 96881
Project: 96881
Buggy source:
public void addSprite(Sprite sprite,Vector2 position){
  sprites.add(sprite);
  spritePositionMap.put(sprite.getID(),position);
}

Fixed version (ground truth):
public void addSprite(Sprite sprite,Vector2 position){
  sprites.add(sprite);
  positions.add(position);
  indices.add(sprites.size() - 1);
}
Program: 96883
Project: 96883
Buggy source:
public SpriteBatch(){
  sprites=new ArrayList<>();
  spritePositionMap=new HashMap<>();
  active=false;
}

Fixed version (ground truth):
public SpriteBatch(){
  sprites=new ArrayList<>();
  indices=new ArrayList<>();
  positions=new ArrayList<>();
  active=false;
}
Program: 96884
Project: 96884
Buggy source:
public void begin(){
  if (active)   throw new SilenceException("String_Node_Str");
  sprites.clear();
  active=true;
}

Fixed version (ground truth):
public void begin(){
  if (active)   throw new SilenceException("String_Node_Str");
  sprites.clear();
  indices.clear();
  positions.clear();
  active=true;
}
Program: 96885
Project: 96885
Buggy source:
/** 
 * Deletes the file resolved by this FilePath instance.
 * @throws IOException      If an I/O error occurs.
 * @throws SilenceException If this file is a resource, or if this doesn't exist.
 */
public void delete() throws IOException {
  if (getType() == Type.RESOURCE)   throw new SilenceException("String_Node_Str");
  if (!exists())   throw new SilenceException("String_Node_Str");
  Files.delete(Paths.get(path));
}

Fixed version (ground truth):
/** 
 * Deletes the file resolved by this FilePath instance.
 * @return True if the attempt is successful or false otherwise.
 * @throws IOException      If an I/O error occurs.
 * @throws SilenceException If this file is a resource, or if this doesn't exist.
 */
public boolean delete() throws IOException {
  if (getType() == Type.RESOURCE)   throw new SilenceException("String_Node_Str");
  if (!exists())   throw new SilenceException("String_Node_Str");
  return Files.deleteIfExists(Paths.get(path));
}
Program: 96886
Project: 96886
Buggy source:
public Vector3 multiplySelf(Matrix4 m){
  float rx=x * m.get(0,0) + y * m.get(0,1) + z * m.get(0,2) + 1 * m.get(0,3);
  float ry=x * m.get(1,0) + y * m.get(1,1) + z * m.get(1,2) + 1 * m.get(1,3);
  float rz=x * m.get(2,0) + y * m.get(2,1) + z * m.get(2,2) + 1 * m.get(2,3);
  return set(rx,ry,rz);
}

Fixed version (ground truth):
public Vector3 multiplySelf(Matrix4 m){
  float rx=x * m.get(0,0) + y * m.get(1,0) + z * m.get(2,0) + 1 * m.get(3,0);
  float ry=x * m.get(0,1) + y * m.get(1,1) + z * m.get(2,1) + 1 * m.get(3,1);
  float rz=x * m.get(0,2) + y * m.get(1,2) + z * m.get(2,2) + 1 * m.get(3,2);
  return set(rx,ry,rz);
}
Program: 96887
Project: 96887
Buggy source:
public void copyTo(FilePath path) throws IOException {
  byte[] buffer=new byte[1024];
  int length;
  try (InputStream inputStream=getInputStream();OutputStream outputStream=path.getOutputStream()){
    while ((length=inputStream.read(buffer)) > 0) {
      outputStream.write(buffer,0,length);
    }
  }
 }

Fixed version (ground truth):
public void copyTo(FilePath path) throws IOException {
  if (isDirectory() && path.isFile())   throw new SilenceException("String_Node_Str");
  if (isFile() && path.isDirectory())   throw new SilenceException("String_Node_Str");
  if (!exists())   throw new SilenceException("String_Node_Str");
  byte[] buffer=new byte[1024];
  int length;
  try (InputStream inputStream=getInputStream();OutputStream outputStream=path.getOutputStream()){
    while ((length=inputStream.read(buffer)) > 0) {
      outputStream.write(buffer,0,length);
    }
  }
 }
Program: 96888
Project: 96888
Buggy source:
public FilePath getParent() throws IOException {
  String[] parts=path.split("String_Node_Str");
  String path=parts[0];
  for (int i=1; i < parts.length - 1; i++)   path+="String_Node_Str" + parts[i] + "String_Node_Str";
  return new FilePath(path + "String_Node_Str",type);
}

Fixed version (ground truth):
public FilePath getParent() throws IOException {
  String[] parts=path.split("String_Node_Str" + SEPARATOR);
  String path=parts[0];
  for (int i=1; i < parts.length - 1; i++)   path+=SEPARATOR + parts[i] + SEPARATOR;
  return new FilePath(path + SEPARATOR,type);
}
Program: 96889
Project: 96889
Buggy source:
public boolean isDirectory(){
  if (!exists())   return false;
  if (getType() == Type.EXTERNAL)   return Files.isDirectory(Paths.get(path));
 else {
    boolean isDirectory=false;
    try {
      File file=new File(FilePath.class.getProtectionDomain().getCodeSource().getLocation().getPath().replaceAll("String_Node_Str","String_Node_Str"));
      if (file.isFile()) {
        JarFile jarFile=new JarFile(file);
        isDirectory=jarFile.stream().filter(e -> e.getName().startsWith(path)).count() > 1;
        jarFile.close();
      }
 else {
        try {
          isDirectory=Files.isDirectory(Paths.get(FilePath.class.getClassLoader().getResource(path).toURI()));
        }
 catch (        FileSystemNotFoundException fsnfe) {
          isDirectory=path.endsWith("String_Node_Str");
        }
catch (        Exception e) {
          SilenceException.reThrow(e);
        }
      }
    }
 catch (    Exception e) {
      SilenceException.reThrow(e);
    }
    return isDirectory;
  }
}

Fixed version (ground truth):
public boolean isDirectory(){
  if (!exists())   return false;
  if (getType() == Type.EXTERNAL)   return Files.isDirectory(Paths.get(path));
 else {
    boolean isDirectory=false;
    try {
      File file=new File(FilePath.class.getProtectionDomain().getCodeSource().getLocation().getPath().replaceAll("String_Node_Str","String_Node_Str"));
      if (file.isFile()) {
        JarFile jarFile=new JarFile(file);
        isDirectory=jarFile.stream().filter(e -> e.getName().startsWith(path)).count() > 1;
        jarFile.close();
      }
 else {
        URL url=FilePath.class.getClassLoader().getResource(path);
        if (url == null) {
          isDirectory=new File(file,path).isDirectory();
        }
 else {
          final Map<String,String> env=new HashMap<>();
          final String[] array=url.toURI().toString().split("String_Node_Str");
          Path path;
          if (array[0].startsWith("String_Node_Str") || array[0].startsWith("String_Node_Str")) {
            final FileSystem fs=FileSystems.newFileSystem(URI.create(array[0]),env);
            path=fs.getPath(array[1]);
            isDirectory=Files.isDirectory(path);
            fs.close();
          }
 else {
            path=Paths.get(url.toURI());
            isDirectory=Files.isDirectory(path);
          }
        }
      }
    }
 catch (    Exception e) {
      SilenceException.reThrow(e);
    }
    return isDirectory;
  }
}
Program: 96890
Project: 96890
Buggy source:
public void moveTo(FilePath path) throws IOException {
  if (getType() == Type.RESOURCE || path.getType() == Type.EXTERNAL)   throw new SilenceException("String_Node_Str");
  Files.move(Paths.get(this.path),Paths.get(path.getPath()));
}

Fixed version (ground truth):
public void moveTo(FilePath path) throws IOException {
  if (getType() == Type.RESOURCE || path.getType() == Type.RESOURCE)   throw new SilenceException("String_Node_Str");
  Files.move(Paths.get(this.path),Paths.get(path.getPath()));
}
Program: 96891
Project: 96891
Buggy source:
public void drawString(Batcher b,String text,float x,float y,Color col){
  Texture current=Texture.CURRENT;
  b.begin(Primitive.TRIANGLES);
{
    float startX=x;
    Texture page=null;
    for (    char ch : text.toCharArray()) {
      FontChar c=chars[(int)ch];
      if (ch == '\n') {
        y+=fontMetrics.getHeight();
        x=startX;
        continue;
      }
      Texture charPage=fontTexture[chars[ch].page];
      if (page == null || page != charPage) {
        b.flush();
        page=charPage;
        page.bind();
      }
      float minU=c.x / page.getWidth();
      float maxU=(c.x + c.w) / page.getWidth();
      float minV=c.y / page.getHeight();
      float maxV=(c.y + c.h) / page.getHeight();
      b.vertex(x - c.padding,y);
      b.color(col);
      b.texCoord(minU,minV);
      b.vertex(x + chars[ch].w - c.padding,y);
      b.color(col);
      b.texCoord(maxU,minV);
      b.vertex(x - c.padding,y + chars[ch].h);
      b.color(col);
      b.texCoord(minU,maxV);
      b.vertex(x + chars[ch].w - c.padding,y);
      b.color(col);
      b.texCoord(maxU,minV);
      b.vertex(x - c.padding,y + chars[ch].h);
      b.color(col);
      b.texCoord(minU,maxV);
      b.vertex(x + chars[ch].w - c.padding,y + chars[ch].h);
      b.color(col);
      b.texCoord(maxU,maxV);
      x+=c.advance;
    }
  }
  b.end();
  current.bind();
}

Fixed version (ground truth):
public void drawString(Batcher b,String text,float x,float y,Color col){
  if (text == null || text.equals("String_Node_Str"))   return;
  Texture current=Texture.CURRENT;
  b.begin(Primitive.TRIANGLES);
{
    float startX=x;
    Texture page=null;
    for (    char ch : text.toCharArray()) {
      FontChar c=chars[(int)ch];
      if (ch == '\n') {
        y+=fontMetrics.getHeight();
        x=startX;
        continue;
      }
      Texture charPage=fontTexture[chars[ch].page];
      if (page == null || page != charPage) {
        b.flush();
        page=charPage;
        page.bind();
      }
      float minU=c.x / page.getWidth();
      float maxU=(c.x + c.w) / page.getWidth();
      float minV=c.y / page.getHeight();
      float maxV=(c.y + c.h) / page.getHeight();
      b.vertex(x - c.padding,y);
      b.color(col);
      b.texCoord(minU,minV);
      b.vertex(x + chars[ch].w - c.padding,y);
      b.color(col);
      b.texCoord(maxU,minV);
      b.vertex(x - c.padding,y + chars[ch].h);
      b.color(col);
      b.texCoord(minU,maxV);
      b.vertex(x + chars[ch].w - c.padding,y);
      b.color(col);
      b.texCoord(maxU,minV);
      b.vertex(x - c.padding,y + chars[ch].h);
      b.color(col);
      b.texCoord(minU,maxV);
      b.vertex(x + chars[ch].w - c.padding,y + chars[ch].h);
      b.color(col);
      b.texCoord(maxU,maxV);
      x+=c.advance;
    }
  }
  b.end();
  current.bind();
}
Program: 96892
Project: 96892
Buggy source:
public GammaRamp getGammaRamp(){
  ByteBuffer gammaRamp=glfwGetGammaRamp(handle);
  GLFWgammaramp ramp=new GLFWgammaramp(gammaRamp);
  int byteBufferSize=ramp.getSize() * Short.BYTES / Byte.BYTES;
  ShortBuffer rBuffer=ramp.getRed(byteBufferSize).asShortBuffer();
  ShortBuffer gBuffer=ramp.getGreen(byteBufferSize).asShortBuffer();
  ShortBuffer bBuffer=ramp.getBlue(byteBufferSize).asShortBuffer();
  short[] red=new short[ramp.getSize()];
  short[] green=new short[ramp.getSize()];
  short[] blue=new short[ramp.getSize()];
  int i=0;
  while (rBuffer.hasRemaining())   red[i++]=rBuffer.get();
  i=0;
  while (gBuffer.hasRemaining())   green[i++]=gBuffer.get();
  i=0;
  while (bBuffer.hasRemaining())   blue[i++]=bBuffer.get();
  return new GammaRamp(red,green,blue,ramp.getSize());
}

Fixed version (ground truth):
public GammaRamp getGammaRamp(){
  ByteBuffer gammaRamp=glfwGetGammaRamp(handle);
  GLFWgammaramp ramp=new GLFWgammaramp(gammaRamp);
  int byteBufferSize=ramp.getSize() * Short.BYTES;
  ShortBuffer rBuffer=ramp.getRed(byteBufferSize).asShortBuffer();
  ShortBuffer gBuffer=ramp.getGreen(byteBufferSize).asShortBuffer();
  ShortBuffer bBuffer=ramp.getBlue(byteBufferSize).asShortBuffer();
  short[] red=new short[ramp.getSize()];
  short[] green=new short[ramp.getSize()];
  short[] blue=new short[ramp.getSize()];
  int i=0;
  while (rBuffer.hasRemaining())   red[i++]=rBuffer.get();
  i=0;
  while (gBuffer.hasRemaining())   green[i++]=gBuffer.get();
  i=0;
  while (bBuffer.hasRemaining())   blue[i++]=bBuffer.get();
  return new GammaRamp(red,green,blue,ramp.getSize());
}
Program: 96893
Project: 96893
Buggy source:
public void setGammaRamp(GammaRamp gammaRamp){
  GLFWgammaramp ramp=new GLFWgammaramp();
  ByteBuffer rBuffer=BufferUtils.createByteBuffer(gammaRamp.getSize() * Short.BYTES / Byte.BYTES);
  ByteBuffer gBuffer=BufferUtils.createByteBuffer(gammaRamp.getSize() * Short.BYTES / Byte.BYTES);
  ByteBuffer bBuffer=BufferUtils.createByteBuffer(gammaRamp.getSize() * Short.BYTES / Byte.BYTES);
  rBuffer.asShortBuffer().put(gammaRamp.getRed()).flip();
  gBuffer.asShortBuffer().put(gammaRamp.getGreen()).flip();
  bBuffer.asShortBuffer().put(gammaRamp.getBlue()).flip();
  ramp.setRed(rBuffer);
  ramp.setGreen(gBuffer);
  ramp.setBlue(bBuffer);
  ramp.setSize(gammaRamp.getSize());
  ByteBuffer buffer=ramp.buffer();
  glfwSetGammaRamp(handle,buffer);
}

Fixed version (ground truth):
public void setGammaRamp(GammaRamp gammaRamp){
  GLFWgammaramp ramp=new GLFWgammaramp();
  ByteBuffer rBuffer=BufferUtils.createByteBuffer(gammaRamp.getSize() * Short.BYTES);
  ByteBuffer gBuffer=BufferUtils.createByteBuffer(gammaRamp.getSize() * Short.BYTES);
  ByteBuffer bBuffer=BufferUtils.createByteBuffer(gammaRamp.getSize() * Short.BYTES);
  rBuffer.asShortBuffer().put(gammaRamp.getRed()).flip();
  gBuffer.asShortBuffer().put(gammaRamp.getGreen()).flip();
  bBuffer.asShortBuffer().put(gammaRamp.getBlue()).flip();
  ramp.setRed(rBuffer);
  ramp.setGreen(gBuffer);
  ramp.setBlue(bBuffer);
  ramp.setSize(gammaRamp.getSize());
  ByteBuffer buffer=ramp.buffer();
  glfwSetGammaRamp(handle,buffer);
}
Program: 96894
Project: 96894
Buggy source:
public FPSCamera move(Vector3 dir,float amount){
  Vector3 deltaMove=position.add(dir.normalizeSelf().scaleSelf(amount));
  deltaMove.y=0;
  position=position.add(deltaMove);
  return this;
}

Fixed version (ground truth):
public FPSCamera move(Vector3 dir,float amount){
  position.addSelf(dir.normalize().scale(amount));
  return this;
}
Program: 96895
Project: 96895
Buggy source:
public void apply(){
  super.apply();
  Vector3 temp=Vector3.REUSABLE_STACK.pop();
  mView.initIdentity().multiplySelf(TransformUtils.createTranslation(temp.set(position).negateSelf())).multiplySelf(TransformUtils.createRotation(rotation));
  Vector3.REUSABLE_STACK.push(temp);
  GL3Context.enable(GL11.GL_DEPTH_TEST);
}

Fixed version (ground truth):
public void apply(){
  super.apply();
  Vector3 tempVec3=Vector3.REUSABLE_STACK.pop();
  mView.initIdentity().multiplySelf(TransformUtils.createTranslation(tempVec3.set(position).negateSelf())).multiplySelf(TransformUtils.createRotation(rotation));
  Vector3.REUSABLE_STACK.push(tempVec3);
  GL3Context.enable(GL11.GL_DEPTH_TEST);
}
Program: 96896
Project: 96896
Buggy source:
public Vector3 getUp(){
  return rotation.multiply(Vector3.AXIS_Y);
}

Fixed version (ground truth):
public Vector3 getUp(){
  return rotation.multiply(Vector3.AXIS_Y,up);
}
Program: 96897
Project: 96897
Buggy source:
public FPSCamera moveDown(float amount){
  return move(getUp().negate(),amount);
}

Fixed version (ground truth):
public FPSCamera moveDown(float amount){
  return move(getUp().negateSelf(),amount);
}
Program: 96898
Project: 96898
Buggy source:
public void setPosition(Vector3 position){
  this.position.set(position);
}

Fixed version (ground truth):
public FPSCamera setPosition(Vector3 position){
  this.position.set(position);
  return this;
}
Program: 96899
Project: 96899
Buggy source:
public Vector3 getRight(){
  return rotation.multiply(Vector3.AXIS_X);
}

Fixed version (ground truth):
public Vector3 getRight(){
  return rotation.multiply(Vector3.AXIS_X,right);
}
Program: 96900
Project: 96900
Buggy source:
public FPSCamera(float fovy,float aspect,float zNear,float zFar){
  mProj=TransformUtils.createPerspective(fovy,aspect,zNear,zFar).copy();
  mView=new Matrix4();
  position=new Vector3(0,0,1);
  rotation=new Quaternion();
}

Fixed version (ground truth):
public FPSCamera(float fovy,float aspect,float zNear,float zFar){
  mProj=TransformUtils.createPerspective(fovy,aspect,zNear,zFar).copy();
  mView=new Matrix4();
  position=new Vector3(0,0,1);
  rotation=new Quaternion();
  forward=new Vector3();
  right=new Vector3();
  up=new Vector3();
}
Program: 96901
Project: 96901
Buggy source:
public FPSCamera rotateX(float angle){
  Quaternion xRot=new Quaternion(Vector3.AXIS_X,angle);
  rotation=rotation.multiply(xRot);
  return this;
}

Fixed version (ground truth):
public FPSCamera rotateX(float angle){
  angleX+=angle;
  if (angleX < -ANGLE_LIMIT_X || angleX > ANGLE_LIMIT_X) {
    angleX-=angle;
    return this;
  }
  Quaternion tempQuat=Quaternion.REUSABLE_STACK.pop();
  Quaternion xRot=tempQuat.set(Vector3.AXIS_X,angle);
  rotation.multiplySelf(xRot);
  Quaternion.REUSABLE_STACK.push(tempQuat);
  return this;
}
Program: 96902
Project: 96902
Buggy source:
public FPSCamera rotateY(float angle){
  Quaternion yRot=new Quaternion(Vector3.AXIS_Y,angle);
  rotation=yRot.multiply(rotation);
  return this;
}

Fixed version (ground truth):
public FPSCamera rotateY(float angle){
  Quaternion tempQuat=Quaternion.REUSABLE_STACK.pop();
  Quaternion yRot=tempQuat.set(Vector3.AXIS_Y,angle);
  rotation.set(yRot.multiplySelf(rotation));
  Quaternion.REUSABLE_STACK.push(tempQuat);
  return this;
}
Program: 96903
Project: 96903
Buggy source:
public Vector3 getForward(){
  return rotation.multiply(Vector3.AXIS_Z.negate());
}

Fixed version (ground truth):
public Vector3 getForward(){
  return rotation.multiply(Vector3.AXIS_Z.negate(),forward);
}
Program: 96904
Project: 96904
Buggy source:
public ResourceLoader setLogo(Texture logo){
  logo.dispose();
  this.logo=logo;
  return instance;
}

Fixed version (ground truth):
public ResourceLoader setLogo(Texture logo){
  if (this.logo != null)   this.logo.dispose();
  this.logo=logo;
  return instance;
}
Program: 96905
Project: 96905
Buggy source:
public void init(){
  ResourceLoader loader=ResourceLoader.getInstance();
  int fontID1=loader.defineFont("String_Node_Str",TrueTypeFont.STYLE_NORMAL,24);
  int fontID2=loader.defineFont("String_Node_Str",TrueTypeFont.STYLE_ITALIC | TrueTypeFont.STYLE_BOLD,48);
  int textureID=loader.defineTexture("String_Node_Str");
  loader.startLoading();
  texture=loader.getTexture(textureID);
  font1=loader.getFont(fontID1);
  font2=loader.getFont(fontID2);
  cam=new OrthoCam().initProjection(Display.getWidth(),Display.getHeight());
}

Fixed version (ground truth):
public void init(){
  ResourceLoader loader=ResourceLoader.getInstance();
  loader.setRenderProgressCallback(this::customProgressRenderCallback);
  int fontID1=loader.defineFont("String_Node_Str",TrueTypeFont.STYLE_NORMAL,24);
  int fontID2=loader.defineFont("String_Node_Str",TrueTypeFont.STYLE_ITALIC | TrueTypeFont.STYLE_BOLD,48);
  int textureID=loader.defineTexture("String_Node_Str");
  loader.startLoading();
  texture=loader.getTexture(textureID);
  font1=loader.getFont(fontID1);
  font2=loader.getFont(fontID2);
  cam=new OrthoCam().initProjection(Display.getWidth(),Display.getHeight());
}
Program: 96906
Project: 96906
Buggy source:
/** 
 * Invoke the callback with the Game's Batcher and progress using the String provided.
 */
private void invokeRenderProgressCallback(String info){
  renderProgressCallback.invoke(Game.getBatcher(),updateProgress(),info);
}

Fixed version (ground truth):
/** 
 * Invoke the callback with the Game's Batcher and progress using the String provided.
 */
private void invokeRenderProgressCallback(String info){
  renderProgressCallback.invoke(Game.getBatcher(),updateProgress(),info);
  System.out.println(info);
}
Program: 96907
Project: 96907
Buggy source:
public void startLoading(){
  boolean recreateDisplay=Display.isResizable();
  if (recreateDisplay)   Display.setResizable(false);
  invokeRenderProgressCallback("String_Node_Str");
  for (  String texName : texturesToLoad.keySet()) {
    textures.put(texturesToLoad.get(texName),Texture.fromResource(texName));
    numLoaded++;
    invokeRenderProgressCallback(texName);
  }
  for (  String fontName : fontsToLoad.keySet()) {
    String[] parts=fontName.split("String_Node_Str");
    TrueTypeFont font;
    int style=Integer.parseInt(parts[1]);
    int size=Integer.parseInt(parts[2]);
    if (parts[0].endsWith("String_Node_Str")) {
      InputStream ttfStream=FileUtils.getResource(parts[0]);
      font=new TrueTypeFont(ttfStream,style,size,true);
    }
 else {
      font=new TrueTypeFont(parts[0],style,size);
    }
    fonts.put(fontsToLoad.get(fontName),font);
    numLoaded++;
    invokeRenderProgressCallback(fontName);
  }
  for (  String soundName : soundsToLoad.keySet()) {
    sounds.put(soundsToLoad.get(soundName),new Sound(soundName));
    numLoaded++;
    invokeRenderProgressCallback(soundName);
  }
  for (  String modelName : modelsToLoad.keySet()) {
    models.put(modelsToLoad.get(modelName),Model.load(modelName));
    numLoaded++;
    invokeRenderProgressCallback(modelName);
  }
  invokeRenderProgressCallback("String_Node_Str");
  if (recreateDisplay)   Display.setResizable(true);
}

Fixed version (ground truth):
public void startLoading(){
  if (texturesToLoad.size() + soundsToLoad.size() + fontsToLoad.size()+ modelsToLoad.size() == 0)   return;
  renderedProgress=0;
  numLoaded=0;
  boolean recreateDisplay=Display.isResizable() && !Display.isFullScreen();
  if (recreateDisplay)   Display.setResizable(false);
  invokeRenderProgressCallback("String_Node_Str");
  for (  String texName : texturesToLoad.keySet()) {
    textures.put(texturesToLoad.get(texName),Texture.fromResource(texName));
    numLoaded++;
    invokeRenderProgressCallback(texName);
  }
  for (  String fontName : fontsToLoad.keySet()) {
    String[] parts=fontName.split("String_Node_Str");
    TrueTypeFont font;
    int style=Integer.parseInt(parts[1]);
    int size=Integer.parseInt(parts[2]);
    if (parts[0].endsWith("String_Node_Str")) {
      InputStream ttfStream=FileUtils.getResource(parts[0]);
      font=new TrueTypeFont(ttfStream,style,size,true);
    }
 else {
      font=new TrueTypeFont(parts[0],style,size);
    }
    fonts.put(fontsToLoad.get(fontName),font);
    numLoaded++;
    invokeRenderProgressCallback(fontName);
  }
  for (  String soundName : soundsToLoad.keySet()) {
    sounds.put(soundsToLoad.get(soundName),new Sound(soundName));
    numLoaded++;
    invokeRenderProgressCallback(soundName);
  }
  for (  String modelName : modelsToLoad.keySet()) {
    models.put(modelsToLoad.get(modelName),Model.load(modelName));
    numLoaded++;
    invokeRenderProgressCallback(modelName);
  }
  invokeRenderProgressCallback("String_Node_Str");
  if (recreateDisplay)   Display.setResizable(true);
}
Program: 96908
Project: 96908
Buggy source:
public Vector2 rotateSelf(float angle){
  angle=(float)Math.toRadians(angle);
  return set(x * (float)Math.cos(angle) - y * (float)Math.sin(angle),x * (float)Math.sin(angle) + y * (float)Math.cos(angle));
}

Fixed version (ground truth):
public Vector2 rotateSelf(float angle){
  float cos=MathUtils.cos(angle);
  float sin=MathUtils.sin(angle);
  return set(x * cos - y * sin,x * sin + y * cos);
}
Program: 96909
Project: 96909
Buggy source:
public void rotate(float angle){
  if (angle == 0 || this instanceof Circle)   return;
  float width=maxX - minX;
  float height=maxY - minY;
  float originX=width / 2;
  float originY=height / 2;
  minX=minY=Float.POSITIVE_INFINITY;
  maxX=maxY=Float.NEGATIVE_INFINITY;
  for (  Vector2 vertex : vertices) {
    vertex.subtractSelf(originX,originY).rotateSelf(angle).addSelf(originX,originY);
    minX=Math.min(vertex.x,minX);
    minY=Math.min(vertex.y,minY);
    maxX=Math.max(vertex.x,maxX);
    maxY=Math.max(vertex.y,maxY);
  }
  rotation+=angle;
  updateBounds();
}

Fixed version (ground truth):
public void rotate(float angle,float originX,float originY){
  if (angle == 0 || this instanceof Circle)   return;
  for (  Vector2 vertex : vertices)   vertex.subtractSelf(originX,originY).rotateSelf(angle).addSelf(originX,originY);
  rotation+=angle;
}
Program: 96910
Project: 96910
Buggy source:
public void scale(float sx,float sy){
  minX=minY=Float.POSITIVE_INFINITY;
  maxX=maxY=Float.NEGATIVE_INFINITY;
  for (  Vector2 v : vertices) {
    v.scaleSelf(sx,sy);
    minX=Math.min(minX,v.x);
    minY=Math.min(minY,v.y);
    maxX=Math.max(maxX,v.x);
    maxY=Math.max(maxY,v.y);
  }
  updateBounds();
}

Fixed version (ground truth):
public void scale(float sx,float sy){
  vertices.forEach(v -> v.scaleSelf(sx,sy));
}
Program: 96911
Project: 96911
Buggy source:
public void setRotation(float rotation){
  rotate(rotation - this.rotation);
}

Fixed version (ground truth):
public void setRotation(float rotation){
  if (this.rotation == rotation)   return;
  rotate(rotation - this.rotation);
}
Program: 96912
Project: 96912
Buggy source:
private void updateBounds(){
  if (bounds == null)   bounds=new Rectangle();
  bounds.set(position.getX() + minX,position.getY() + minY,maxX - minX,maxY - minY);
}

Fixed version (ground truth):
private void updateBounds(){
  if (bounds == null)   bounds=new Rectangle();
  float minX, minY, maxX, maxY;
  minX=minY=Float.POSITIVE_INFINITY;
  maxX=maxY=Float.NEGATIVE_INFINITY;
  for (  Vector2 vertex : vertices) {
    minX=Math.min(minX,vertex.x);
    minY=Math.min(minY,vertex.y);
    maxX=Math.max(maxX,vertex.x);
    maxY=Math.max(maxY,vertex.y);
  }
  bounds.set(position.getX() + minX,position.getY() + minY,maxX - minX,maxY - minY);
}
Program: 96913
Project: 96913
Buggy source:
public void removeChild(SceneNode child){
  if (child.getParent() != this)   throw new SilenceException("String_Node_Str");
  if (children == null)   return;
  child.destroy();
  children.remove(child);
  child.setParent(null);
}

Fixed version (ground truth):
public void removeChild(SceneNode child){
  if (child.getParent() != this)   throw new SilenceException("String_Node_Str");
  if (children == null)   return;
  if (!child.isDestroyed())   child.destroy();
  children.remove(child);
  child.setParent(null);
}
Program: 96914
Project: 96914
Buggy source:
/** 
 * Sets the state of fullscreen of the Display.
 * @param fullScreen If true, window will be made fullscreen
 */
public static void setFullScreen(boolean fullScreen){
  if (Display.fullScreen == fullScreen)   return;
  Display.fullScreen=fullScreen;
  if (fullScreen) {
    VideoMode videoMode=Monitor.getPrimaryMonitor().getVideoMode();
    oldWidth=width;
    oldHeight=height;
    oldPosX=posX;
    oldPosY=posY;
    width=videoMode.getWidth();
    height=videoMode.getHeight();
  }
 else {
    width=oldWidth;
    height=oldHeight;
    posX=oldPosX;
    posY=oldPosY;
  }
  Window fsDisplayWindow=createWindow(width,height,title,fullScreen ? Monitor.getPrimaryMonitor() : null,displayWindow,true,resizable);
  displayWindow.destroy();
  displayWindow=fsDisplayWindow;
  setPosition(posX,posY);
  show();
  update();
}

Fixed version (ground truth):
/** 
 * Sets the state of fullscreen of the Display.
 * @param fullScreen If true, window will be made fullscreen
 */
public static void setFullScreen(boolean fullScreen){
  if (Display.fullScreen == fullScreen)   return;
  Display.fullScreen=fullScreen;
  if (fullScreen) {
    VideoMode videoMode=Monitor.getPrimaryMonitor().getVideoMode();
    oldWidth=width;
    oldHeight=height;
    oldPosX=posX;
    oldPosY=posY;
    width=videoMode.getWidth();
    height=videoMode.getHeight();
  }
 else {
    width=oldWidth;
    height=oldHeight;
    posX=oldPosX;
    posY=oldPosY;
  }
  Window fsDisplayWindow=createWindow(width,height,title,fullScreen ? Monitor.getPrimaryMonitor() : null,displayWindow,false,resizable);
  displayWindow.destroy();
  displayWindow=fsDisplayWindow;
  setPosition(posX,posY);
  setSize(width,height);
  hide();
  show();
  update();
}