nus-yam/ex-repair huggingface dataset:
Program: 96985
Project: 96985
Buggy source:
/** 
 * Uploads the data collected to the OpenGL buffers.
 */
private void uploadData(){
  vboVert.bind();
  vboVert.uploadSubData(vBuffer,0);
  vao.pointAttribute(vertexLocation,4,GL_FLOAT,vboVert);
  vboCol.bind();
  vboCol.uploadSubData(cBuffer,0);
  vao.pointAttribute(colorLocation,4,GL_FLOAT,vboCol);
  vboTex.bind();
  vboTex.uploadSubData(tBuffer,0);
  vao.pointAttribute(texCoordLocation,2,GL_FLOAT,vboTex);
  vboNorm.bind();
  vboNorm.uploadSubData(nBuffer,0);
  vao.pointAttribute(normalLocation,4,GL_FLOAT,vboNorm);
}

Fixed version (ground truth):
/** 
 * Uploads the data collected to the OpenGL buffers.
 */
private void uploadData(){
  vboVert.bind();
  vboVert.uploadData(vBuffer,GL_STREAM_DRAW);
  vao.pointAttribute(vertexLocation,4,GL_FLOAT,vboVert);
  vboCol.bind();
  vboCol.uploadData(cBuffer,GL_STREAM_DRAW);
  vao.pointAttribute(colorLocation,4,GL_FLOAT,vboCol);
  vboTex.bind();
  vboTex.uploadData(tBuffer,GL_STREAM_DRAW);
  vao.pointAttribute(texCoordLocation,2,GL_FLOAT,vboTex);
  vboNorm.bind();
  vboNorm.uploadData(nBuffer,GL_STREAM_DRAW);
  vao.pointAttribute(normalLocation,4,GL_FLOAT,vboNorm);
}
Program: 96986
Project: 96986
Buggy source:
public void update(float delta){
  if (Keyboard.isClicked(Keyboard.KEY_ESCAPE))   end();
  cube.getPosition().x=(float)Math.sin(TimeUtils.currentSeconds()) * 2;
  cube.getPosition().y=cube.getPosition().x;
  cube.getPosition().z=cube.getPosition().x;
  sphere.getPosition().x=-cube.getPosition().x;
  sphere.getPosition().y=-cube.getPosition().y;
  sphere.getPosition().z=-cube.getPosition().z;
  if (Keyboard.isPressed(Keyboard.KEY_W))   camera.moveForward(delta);
  if (Keyboard.isPressed(Keyboard.KEY_S))   camera.moveBackward(delta);
  if (Keyboard.isPressed(Keyboard.KEY_A))   camera.moveLeft(delta);
  if (Keyboard.isPressed(Keyboard.KEY_D))   camera.moveRight(delta);
  if (Keyboard.isPressed(Keyboard.KEY_Q))   camera.moveUp(delta);
  if (Keyboard.isPressed(Keyboard.KEY_E))   camera.moveDown(delta);
  if (Keyboard.isPressed(Keyboard.KEY_UP))   camera.rotateX(1);
  if (Keyboard.isPressed(Keyboard.KEY_DOWN))   camera.rotateX(-1);
  if (Keyboard.isPressed(Keyboard.KEY_LEFT))   camera.rotateY(1);
  if (Keyboard.isPressed(Keyboard.KEY_RIGHT))   camera.rotateY(-1);
}

Fixed version (ground truth):
public void update(float delta){
  if (Keyboard.isClicked(Keyboard.KEY_ESCAPE))   end();
  if (!Keyboard.isPressed(Keyboard.KEY_SPACE)) {
    float movement=(float)Math.sin(TimeUtils.currentSeconds()) * 2;
    cube.getPosition().x=movement;
    cube.getPosition().y=movement;
    cube.getPosition().z=movement;
    sphere.getPosition().x=-movement;
    sphere.getPosition().y=-movement;
    sphere.getPosition().z=-movement;
  }
  if (Keyboard.isPressed(Keyboard.KEY_W))   camera.moveForward(delta);
  if (Keyboard.isPressed(Keyboard.KEY_S))   camera.moveBackward(delta);
  if (Keyboard.isPressed(Keyboard.KEY_A))   camera.moveLeft(delta);
  if (Keyboard.isPressed(Keyboard.KEY_D))   camera.moveRight(delta);
  if (Keyboard.isPressed(Keyboard.KEY_Q))   camera.moveUp(delta);
  if (Keyboard.isPressed(Keyboard.KEY_E))   camera.moveDown(delta);
  if (Keyboard.isPressed(Keyboard.KEY_UP))   camera.rotateX(1);
  if (Keyboard.isPressed(Keyboard.KEY_DOWN))   camera.rotateX(-1);
  if (Keyboard.isPressed(Keyboard.KEY_LEFT))   camera.rotateY(1);
  if (Keyboard.isPressed(Keyboard.KEY_RIGHT))   camera.rotateY(-1);
}
Program: 96987
Project: 96987
Buggy source:
public void render(float delta,Batcher batcher){
  camera.apply();
  if (!sphere.intersects(cube)) {
    RenderUtils.fillPolyhedron(batcher,cube,Color.CORN_FLOWER_BLUE);
    RenderUtils.fillPolyhedron(batcher,sphere,Color.INDIAN_RED);
  }
  RenderUtils.tracePolyhedron(batcher,cube,Color.GREEN);
  RenderUtils.tracePolyhedron(batcher,sphere,Color.GREEN);
}

Fixed version (ground truth):
public void render(float delta,Batcher batcher){
  camera.apply();
  if (!sphere.intersects(cube)) {
    RenderUtils.fillPolyhedron(batcher,cube,Color.BLUE);
    RenderUtils.fillPolyhedron(batcher,sphere,Color.DARK_RED);
  }
  RenderUtils.tracePolyhedron(batcher,cube,Color.GREEN);
  RenderUtils.tracePolyhedron(batcher,sphere,Color.GREEN);
}
Program: 96988
Project: 96988
Buggy source:
public static void tracePolyhedron(Batcher b,Polyhedron polyhedron,Vector3 position,Color color){
  b.begin(Primitive.LINE_STRIP);
{
    for (    Vector3 vertex : polyhedron.getVertices()) {
      b.vertex(vertex.add(polyhedron.getPosition().add(position)));
      b.color(color);
    }
  }
  b.end();
}

Fixed version (ground truth):
public static void tracePolyhedron(Batcher b,Polyhedron polyhedron,Vector3 position,Color color){
  b.begin(Primitive.LINE_STRIP);
{
    Vector3 v1;
    Vector3 v2;
    Vector3 v3;
    for (int v=0; v < polyhedron.vertexCount() - 2; v++) {
      if ((v & 1) != 0) {
        v1=polyhedron.getVertex(v);
        v2=polyhedron.getVertex(v + 1);
        v3=polyhedron.getVertex(v + 2);
      }
 else {
        v1=polyhedron.getVertex(v);
        v2=polyhedron.getVertex(v + 2);
        v3=polyhedron.getVertex(v + 1);
      }
      v1=v1.add(polyhedron.getPosition()).add(position);
      v2=v2.add(polyhedron.getPosition()).add(position);
      v3=v3.add(polyhedron.getPosition()).add(position);
      b.vertex(v1);
      b.color(color);
      b.vertex(v2);
      b.color(color);
      b.vertex(v3);
      b.color(color);
    }
  }
  b.end();
}
Program: 96989
Project: 96989
Buggy source:
public void dispose(){
  for (  int id : textures.keySet())   textures.get(id).dispose();
  for (  int id : fonts.keySet())   fonts.get(id).dispose();
}

Fixed version (ground truth):
public void dispose(){
  for (  int id : textures.keySet())   textures.get(id).dispose();
  for (  int id : fonts.keySet())   fonts.get(id).dispose();
  for (  int id : sounds.keySet())   sounds.get(id).dispose();
}
Program: 96990
Project: 96990
Buggy source:
public void rotate(float angle){
  angle=(float)Math.toRadians(angle);
  if (angle == 0 || this instanceof Circle)   return;
  float s=(float)Math.sin(angle);
  float c=(float)Math.cos(angle);
  float width=maxX - minX;
  float height=maxY - minY;
  float originX=width / 2;
  float originY=height / 2;
  float minX, maxX, minY, maxY;
  minX=minY=Float.POSITIVE_INFINITY;
  maxX=maxY=Float.NEGATIVE_INFINITY;
  for (  Vector2 vertex : vertices) {
    Vector2 v=vertex.subtract(originX,originY);
    float xNew=v.getX() * c - v.getY() * s;
    float yNew=v.getX() * s + v.getY() * c;
    vertex.setX(xNew + originX);
    vertex.setY(yNew + originY);
    minX=Math.min(xNew + originX,minX);
    minY=Math.min(yNew + originY,minY);
    maxX=Math.max(xNew + originX,maxX);
    maxY=Math.max(yNew + originY,maxY);
  }
  rotation+=angle;
  bounds=new Rectangle(position.getX() + minX,position.getY() + minY,maxX - minX,maxY - minY);
}

Fixed version (ground truth):
public void rotate(float angle){
  angle=(float)Math.toRadians(angle);
  if (angle == 0 || this instanceof Circle)   return;
  float s=(float)Math.sin(angle);
  float c=(float)Math.cos(angle);
  float width=maxX - minX;
  float height=maxY - minY;
  float originX=width / 2;
  float originY=height / 2;
  float minX, maxX, minY, maxY;
  minX=minY=Float.POSITIVE_INFINITY;
  maxX=maxY=Float.NEGATIVE_INFINITY;
  for (  Vector2 vertex : vertices) {
    Vector2 v=vertex.subtract(originX,originY);
    float xNew=v.getX() * c - v.getY() * s;
    float yNew=v.getX() * s + v.getY() * c;
    vertex.setX(xNew + originX);
    vertex.setY(yNew + originY);
    minX=Math.min(xNew + originX,minX);
    minY=Math.min(yNew + originY,minY);
    maxX=Math.max(xNew + originX,maxX);
    maxY=Math.max(yNew + originY,maxY);
  }
  rotation+=Math.toDegrees(angle);
  bounds=new Rectangle(position.getX() + minX,position.getY() + minY,maxX - minX,maxY - minY);
}
Program: 96991
Project: 96991
Buggy source:
public Vector2 rotate(float angle){
  return null;
}

Fixed version (ground truth):
public Vector2 rotate(float angle){
  angle=(float)Math.toRadians(angle);
  return new Vector2(x * (float)Math.cos(angle) - y * (float)Math.sin(angle),x * (float)Math.sin(angle) + y * (float)Math.cos(angle));
}
Program: 96992
Project: 96992
Buggy source:
public void update(float delta){
  transform.rotate(Vector3.AXIS_Y,4 * delta);
  if (Keyboard.isPressed(Keyboard.KEY_ESCAPE))   end();
  float speed=2 * delta;
  if (Keyboard.isPressed(Keyboard.KEY_W))   perspCam.moveForward(speed);
  if (Keyboard.isPressed(Keyboard.KEY_S))   perspCam.moveBackward(speed);
  if (Keyboard.isPressed(Keyboard.KEY_A))   perspCam.moveLeft(speed);
  if (Keyboard.isPressed(Keyboard.KEY_D))   perspCam.moveRight(speed);
  if (Keyboard.isPressed(Keyboard.KEY_Q))   perspCam.moveUp(speed);
  if (Keyboard.isPressed(Keyboard.KEY_E))   perspCam.moveDown(speed);
  if (Keyboard.isPressed(Keyboard.KEY_UP))   perspCam.rotateX(1);
  if (Keyboard.isPressed(Keyboard.KEY_DOWN))   perspCam.rotateX(-1);
  if (Keyboard.isPressed(Keyboard.KEY_LEFT))   perspCam.rotateY(1);
  if (Keyboard.isPressed(Keyboard.KEY_RIGHT))   perspCam.rotateY(-1);
  if (Keyboard.isPressed(Keyboard.KEY_SPACE)) {
    perspCam.rotateX(-Mouse.getDY() * speed);
    perspCam.rotateY(-Mouse.getDX() * speed);
  }
}

Fixed version (ground truth):
public void update(float delta){
  transform.rotate(Vector3.AXIS_Y,60 * delta);
  if (Keyboard.isPressed(Keyboard.KEY_ESCAPE))   end();
  float speed=2 * delta;
  if (Keyboard.isPressed(Keyboard.KEY_W))   perspCam.moveForward(speed);
  if (Keyboard.isPressed(Keyboard.KEY_S))   perspCam.moveBackward(speed);
  if (Keyboard.isPressed(Keyboard.KEY_A))   perspCam.moveLeft(speed);
  if (Keyboard.isPressed(Keyboard.KEY_D))   perspCam.moveRight(speed);
  if (Keyboard.isPressed(Keyboard.KEY_Q))   perspCam.moveUp(speed);
  if (Keyboard.isPressed(Keyboard.KEY_E))   perspCam.moveDown(speed);
  if (Keyboard.isPressed(Keyboard.KEY_UP))   perspCam.rotateX(1);
  if (Keyboard.isPressed(Keyboard.KEY_DOWN))   perspCam.rotateX(-1);
  if (Keyboard.isPressed(Keyboard.KEY_LEFT))   perspCam.rotateY(1);
  if (Keyboard.isPressed(Keyboard.KEY_RIGHT))   perspCam.rotateY(-1);
  if (Keyboard.isPressed(Keyboard.KEY_SPACE)) {
    perspCam.rotateX(-Mouse.getDY() * speed);
    perspCam.rotateY(-Mouse.getDX() * speed);
  }
}
Program: 96993
Project: 96993
Buggy source:
public void update(float delta){
  rotation+=(float)(4.0 * delta);
  float z=-Math.abs((float)Math.sin(rotation));
  getLocalTransform().reset().rotate(Vector3.AXIS_Z,rotation).translate(new Vector3(position.getX(),position.getY(),z));
}

Fixed version (ground truth):
public void update(float delta){
  rotation+=60 * delta;
  float z=-Math.abs((float)Math.sin(TimeUtils.currentSeconds()));
  getLocalTransform().reset().rotate(Vector3.AXIS_Z,rotation).translate(new Vector3(position.getX(),position.getY(),z));
}
Program: 96995
Project: 96995
Buggy source:
public void prepareFrame(){
  Batcher batcher=Game.getBatcher();
  setUniform("String_Node_Str",Texture.getActiveUnit());
  setUniform("String_Node_Str",batcher.getTransform().getMatrix());
  setUniform("String_Node_Str",BaseCamera.projection);
  setUniform("String_Node_Str",BaseCamera.view);
  batcher.setVertexLocation(0);
  batcher.setColorLocation(1);
  batcher.setTexCoordLocation(2);
  batcher.setNormalLocation(3);
}

Fixed version (ground truth):
public void prepareFrame(){
  Batcher batcher=Game.getBatcher();
  GL3Context.enable(GL11.GL_BLEND);
  GL3Context.blendFunc(GL11.GL_SRC_ALPHA,GL11.GL_ONE_MINUS_SRC_ALPHA);
  setUniform("String_Node_Str",Texture.getActiveUnit());
  setUniform("String_Node_Str",batcher.getTransform().getMatrix());
  setUniform("String_Node_Str",BaseCamera.projection);
  setUniform("String_Node_Str",BaseCamera.view);
  batcher.setVertexLocation(0);
  batcher.setColorLocation(1);
  batcher.setTexCoordLocation(2);
  batcher.setNormalLocation(3);
}
Program: 96996
Project: 96996
Buggy source:
public void apply(){
  BaseCamera.projection=mProj;
  BaseCamera.view=mView;
}

Fixed version (ground truth):
public void apply(){
  BaseCamera.projection=mProj;
  BaseCamera.view=mView;
  GL3Context.disable(GL11.GL_DEPTH_TEST);
}
Program: 96997
Project: 96997
Buggy source:
public void apply(){
  mView=TransformUtils.createRotation(rotation);
  mView=TransformUtils.createTranslation(position.negate()).multiply(mView);
  BaseCamera.projection=mProj;
  BaseCamera.view=mView;
}

Fixed version (ground truth):
public void apply(){
  mView=TransformUtils.createRotation(rotation);
  mView=TransformUtils.createTranslation(position.negate()).multiply(mView);
  BaseCamera.projection=mProj;
  BaseCamera.view=mView;
  GL3Context.enable(GL11.GL_DEPTH_TEST);
}
Program: 96998
Project: 96998
Buggy source:
private void createSet(){
  BufferedImage tmp=new BufferedImage(1,1,BufferedImage.TYPE_INT_ARGB);
  Graphics2D g2d=tmp.createGraphics();
  g2d.setFont(awtFont);
  if (antiAlias)   g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
  fontMetrics=g2d.getFontMetrics();
  int textureWidth=0;
  int textureHeight=0;
  int positionX=0;
  int positionY=0;
  for (int i=0; i < STANDARD_CHARACTERS; i++) {
    char ch=(char)i;
    chars[i]=new FontChar();
    if (positionX + fontMetrics.charWidth(ch) > 512) {
      textureHeight+=fontMetrics.getHeight();
      positionX=0;
      positionY=textureHeight;
    }
    textureWidth=Math.max(textureWidth,positionX);
    chars[i].x=positionX;
    chars[i].y=positionY;
    chars[i].w=fontMetrics.stringWidth("String_Node_Str" + ch) - fontMetrics.charWidth('_');
    chars[i].h=fontMetrics.getHeight();
    positionX+=chars[i].w + 5;
  }
  g2d.dispose();
  BufferedImage texImage=new BufferedImage(textureWidth,textureHeight,BufferedImage.TYPE_INT_ARGB);
  g2d=texImage.createGraphics();
  g2d.setFont(awtFont);
  g2d.setColor(java.awt.Color.BLACK);
  if (antiAlias)   g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
  for (int i=0; i < STANDARD_CHARACTERS; i++) {
    g2d.drawString(String.valueOf((char)i),chars[i].x,chars[i].y + fontMetrics.getAscent());
  }
  g2d.dispose();
  fontTexture=Texture.fromBufferedImage(texImage);
}

Fixed version (ground truth):
private void createSet(){
  BufferedImage tmp=new BufferedImage(1,1,BufferedImage.TYPE_INT_ARGB);
  Graphics2D g2d=tmp.createGraphics();
  g2d.setFont(awtFont);
  if (antiAlias)   g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
  fontMetrics=g2d.getFontMetrics();
  int textureWidth=0;
  int textureHeight=0;
  int positionX=0;
  int positionY=0;
  for (int i=0; i < STANDARD_CHARACTERS; i++) {
    char ch=(char)i;
    chars[i]=new FontChar();
    if (positionX + fontMetrics.charWidth(ch) > 512) {
      textureHeight+=fontMetrics.getHeight() + 16;
      positionX=0;
      positionY=textureHeight;
    }
    textureWidth=Math.max(textureWidth,positionX);
    chars[i].x=positionX;
    chars[i].y=positionY;
    chars[i].w=fontMetrics.stringWidth("String_Node_Str" + ch) - fontMetrics.charWidth('_');
    chars[i].h=fontMetrics.getHeight();
    positionX+=chars[i].w + 5;
  }
  g2d.dispose();
  BufferedImage texImage=new BufferedImage(textureWidth,textureHeight,BufferedImage.TYPE_INT_ARGB);
  g2d=texImage.createGraphics();
  g2d.setFont(awtFont);
  g2d.setColor(java.awt.Color.BLACK);
  if (antiAlias)   g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
  for (int i=0; i < STANDARD_CHARACTERS; i++) {
    g2d.drawString(String.valueOf((char)i),chars[i].x,chars[i].y + fontMetrics.getAscent());
  }
  g2d.dispose();
  fontTexture=Texture.fromBufferedImage(texImage);
}
Program: 96999
Project: 96999
Buggy source:
/** 
 * Constructs a Entity2D to use a Polygon that can be used to perform collisions.
 * @param polygon The collision mask.
 */
public Entity2D(Polygon polygon){
  this.polygon=polygon;
}

Fixed version (ground truth):
/** 
 * Constructs a Entity2D to use a Polygon that can be used to perform collisions.
 * @param polygon The collision mask.
 */
public Entity2D(Polygon polygon){
  this();
  this.polygon=polygon;
}
Program: 97000
Project: 97000
Buggy source:
/** 
 * Prepares this Entity2D for a new frame. This method is not meant to be called by the user and is called by the SceneGraph.
 * @param delta The delta time.
 */
public void preUpdate(float delta){
  update(delta);
  if (velocity == Vector2.ZERO)   return;
  position=position.add(velocity);
  polygon.setPosition(position);
  getLocalTransform().reset().rotate(Vector3.AXIS_Z,polygon.getRotation()).translate(position);
}

Fixed version (ground truth):
/** 
 * Prepares this Entity2D for a new frame. This method is not meant to be called by the user and is called by the SceneGraph.
 * @param delta The delta time.
 */
public void preUpdate(float delta){
  update(delta);
  if (velocity == Vector2.ZERO)   return;
  position=position.add(velocity);
  polygon.setPosition(position);
  getLocalTransform().reset().translate(getPosition().subtract(getCenter())).rotate(Vector3.AXIS_Z,polygon.getRotation()).translate(getCenter());
}
Program: 97001
Project: 97001
Buggy source:
public void drawTexture2d(Texture texture,Vector2 p,Color color){
  Texture current=Texture.CURRENT;
  flush();
  texture.bind();
{
    vertex(p.getX(),p.getY(),0,1);
    color(color);
    texCoord(texture.getMinU(),texture.getMinV());
    vertex(p.getX() + texture.getWidth(),p.getY(),0,1);
    color(color);
    texCoord(texture.getMaxU(),texture.getMinV());
    vertex(p.getX(),p.getY() + texture.getHeight(),0,1);
    color(color);
    texCoord(texture.getMinU(),texture.getMaxV());
  }
{
    vertex(p.getX() + texture.getWidth(),p.getY(),0,1);
    color(color);
    texCoord(texture.getMaxU(),texture.getMinV());
    vertex(p.getX(),p.getY() + texture.getHeight(),0,1);
    color(color);
    texCoord(texture.getMinU(),texture.getMaxV());
    vertex(p.getX() + texture.getWidth(),p.getY() + texture.getHeight(),0,1);
    color(color);
    texCoord(texture.getMaxU(),texture.getMaxV());
  }
  flush();
  current.bind();
}

Fixed version (ground truth):
public void drawTexture2d(Texture texture,Vector2 p,Color color){
  Texture current=Texture.CURRENT;
  texture.bind();
  begin();
{
    vertex(p.getX(),p.getY(),0,1);
    color(color);
    texCoord(texture.getMinU(),texture.getMinV());
    vertex(p.getX() + texture.getWidth(),p.getY(),0,1);
    color(color);
    texCoord(texture.getMaxU(),texture.getMinV());
    vertex(p.getX(),p.getY() + texture.getHeight(),0,1);
    color(color);
    texCoord(texture.getMinU(),texture.getMaxV());
  }
{
    vertex(p.getX() + texture.getWidth(),p.getY(),0,1);
    color(color);
    texCoord(texture.getMaxU(),texture.getMinV());
    vertex(p.getX(),p.getY() + texture.getHeight(),0,1);
    color(color);
    texCoord(texture.getMinU(),texture.getMaxV());
    vertex(p.getX() + texture.getWidth(),p.getY() + texture.getHeight(),0,1);
    color(color);
    texCoord(texture.getMaxU(),texture.getMaxV());
  }
  end();
  current.bind();
}
Program: 97004
Project: 97004
Buggy source:
/** 
 * Loads the natives from the JAR resources
 */
public static void load(){
  if (System.getProperty("String_Node_Str","String_Node_Str").equalsIgnoreCase("String_Node_Str"))   return;
  try {
    File tmp=Files.createTempDirectory("String_Node_Str").toFile();
    tmp.deleteOnExit();
    if (OS.contains("String_Node_Str")) {
      if (ARCH.contains("String_Node_Str")) {
        extractLibrary(tmp,"String_Node_Str");
        extractLibrary(tmp,"String_Node_Str");
      }
 else {
        extractLibrary(tmp,"String_Node_Str");
        extractLibrary(tmp,"String_Node_Str");
      }
    }
 else     if (OS.contains("String_Node_Str")) {
      extractLibrary(tmp,"String_Node_Str");
      extractLibrary(tmp,"String_Node_Str");
    }
 else     if (OS.contains("String_Node_Str")) {
      if (ARCH.contains("String_Node_Str")) {
        extractLibrary(tmp,"String_Node_Str");
        extractLibrary(tmp,"String_Node_Str");
      }
 else {
        extractLibrary(tmp,"String_Node_Str");
        extractLibrary(tmp,"String_Node_Str");
      }
    }
    System.setProperty("String_Node_Str",tmp.getAbsolutePath());
  }
 catch (  Exception e) {
    throw new SilenceException(e.getMessage());
  }
}

Fixed version (ground truth):
/** 
 * Loads the natives from the JAR resources
 */
public static void load(){
  if (System.getProperty("String_Node_Str","String_Node_Str").equalsIgnoreCase("String_Node_Str"))   return;
  try {
    File tmp=Files.createTempDirectory("String_Node_Str").toFile();
    tmp.deleteOnExit();
    if (isWindows) {
      if (!is64Bit) {
        extractLibrary(tmp,"String_Node_Str");
        extractLibrary(tmp,"String_Node_Str");
      }
 else {
        extractLibrary(tmp,"String_Node_Str");
        extractLibrary(tmp,"String_Node_Str");
      }
    }
 else     if (isMac) {
      extractLibrary(tmp,"String_Node_Str");
      extractLibrary(tmp,"String_Node_Str");
    }
 else     if (isLinux) {
      if (!is64Bit) {
        extractLibrary(tmp,"String_Node_Str");
        extractLibrary(tmp,"String_Node_Str");
      }
 else {
        extractLibrary(tmp,"String_Node_Str");
        extractLibrary(tmp,"String_Node_Str");
      }
    }
    System.setProperty("String_Node_Str",tmp.getAbsolutePath());
  }
 catch (  Exception e) {
    SilenceException.reThrow(e);
  }
}
Program: 97005
Project: 97005
Buggy source:
private static void releaseCallbacks(){
  if (winSizeCallback != null)   winSizeCallback.release();
  if (winKeyCallback != null)   winKeyCallback.release();
  if (winPosCallback != null)   winPosCallback.release();
  if (winCurPosCallback != null)   winCurPosCallback.release();
  if (winScrollCallback != null)   winScrollCallback.release();
  if (winMouseButtonCallback != null)   winMouseButtonCallback.release();
}

Fixed version (ground truth):
/** 
 * Used to release GLFW callbacks. This is necessary to prevent segmentation fault errors in native code.
 */
private static void releaseCallbacks(){
  if (winSizeCallback != null)   winSizeCallback.release();
  if (winKeyCallback != null)   winKeyCallback.release();
  if (winPosCallback != null)   winPosCallback.release();
  if (winCurPosCallback != null)   winCurPosCallback.release();
  if (winScrollCallback != null)   winScrollCallback.release();
  if (winMouseButtonCallback != null)   winMouseButtonCallback.release();
}
Program: 97006
Project: 97006
Buggy source:
/** 
 * Starts the game. Initiates the game life-cycle and starts the main game-loop.
 */
public void start(){
  running=true;
  Display.create();
  Display.show();
  init();
  final double frameTime=1.0 / targetUPS;
  double currentTime;
  double previousTime;
  double elapsed;
  double lag=0;
  double lastUPSUpdate=0;
  double lastFPSUpdate=0;
  int updatesProcessed=0;
  int framesProcessed=0;
  previousTime=0;
  while (true) {
    if (Display.isCloseRequested() || !isRunning())     break;
    if (Display.wasResized()) {
      GL3Context.viewport(0,0,Display.getWidth(),Display.getHeight());
      resize();
    }
    currentTime=TimeUtils.currentSeconds();
    elapsed=currentTime - previousTime;
    lag+=elapsed;
    while (lag > frameTime) {
      Keyboard.startEventFrame();
      Mouse.startEventFrame();
      update((float)elapsed);
      Keyboard.clearEventFrame();
      Mouse.clearEventFrame();
      updatesProcessed++;
      lag-=frameTime;
      if (currentTime - lastUPSUpdate >= 1000) {
        ups=updatesProcessed;
        updatesProcessed=0;
        lastUPSUpdate=currentTime;
      }
    }
    GL3Context.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    Texture.setActiveUnit(0);
    render((float)elapsed,batcher);
    framesProcessed++;
    if (currentTime - lastFPSUpdate >= 1000) {
      fps=framesProcessed;
      framesProcessed=0;
      lastFPSUpdate=currentTime;
    }
    Display.update();
    previousTime=currentTime;
  }
  batcher.dispose();
  dispose();
  Display.destroy();
}

Fixed version (ground truth):
/** 
 * Starts the game. Initiates the game life-cycle and starts the main game-loop.
 */
public void start(){
  running=true;
  Display.create();
  Display.show();
  init();
  final double frameTime=1.0 / targetUPS;
  double currentTime;
  double previousTime;
  double elapsed;
  double lag=0;
  double lastUPSUpdate=0;
  double lastFPSUpdate=0;
  int updatesProcessed=0;
  int framesProcessed=0;
  previousTime=0;
  while (true) {
    if (Display.isCloseRequested() || !isRunning())     break;
    if (Display.wasResized()) {
      GL3Context.viewport(0,0,Display.getWidth(),Display.getHeight());
      resize();
    }
    currentTime=TimeUtils.currentSeconds();
    elapsed=currentTime - previousTime;
    lag+=elapsed;
    while (lag > frameTime) {
      Keyboard.startEventFrame();
      Mouse.startEventFrame();
      update((float)elapsed);
      Keyboard.clearEventFrame();
      Mouse.clearEventFrame();
      updatesProcessed++;
      lag-=frameTime;
      if (currentTime - lastUPSUpdate >= 1000) {
        ups=updatesProcessed;
        updatesProcessed=0;
        lastUPSUpdate=currentTime;
      }
    }
    float lagOffset=(float)(lag / frameTime);
    GL3Context.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    Texture.setActiveUnit(0);
    render(lagOffset,batcher);
    framesProcessed++;
    if (currentTime - lastFPSUpdate >= 1000) {
      fps=framesProcessed;
      framesProcessed=0;
      lastFPSUpdate=currentTime;
    }
    Display.update();
    previousTime=currentTime;
  }
  batcher.dispose();
  dispose();
  Display.destroy();
}
Program: 97008
Project: 97008
Buggy source:
/** 
 * Initialises VAOs and VBOs and creates the data store to store the entire batch.
 */
private void initGLHandles(){
  vao=new VertexArrayObject();
  vao.bind();
  vboVert=new VertexBufferObject(GL_ARRAY_BUFFER);
  vboCol=new VertexBufferObject(GL_ARRAY_BUFFER);
  vboTex=new VertexBufferObject(GL_ARRAY_BUFFER);
  vboVert.bind();
  vboVert.uploadData(SIZE_OF_VERTEX * MAX_VERTICES_IN_BATCH,GL_STREAM_DRAW);
  vboCol.bind();
  vboCol.uploadData(SIZE_OF_COLOR * MAX_VERTICES_IN_BATCH,GL_STREAM_DRAW);
  vboTex.bind();
  vboTex.uploadData(SIZE_OF_TEXCOORD * MAX_VERTICES_IN_BATCH,GL_STREAM_DRAW);
}

Fixed version (ground truth):
/** 
 * Initialises VAOs and VBOs and creates the data store to store the entire batch.
 */
private void initGLHandles(){
  vao=new VertexArrayObject();
  vao.bind();
  vboVert=new VertexBufferObject(GL_ARRAY_BUFFER);
  vboCol=new VertexBufferObject(GL_ARRAY_BUFFER);
  vboTex=new VertexBufferObject(GL_ARRAY_BUFFER);
  vboNorm=new VertexBufferObject(GL_ARRAY_BUFFER);
  vboVert.bind();
  vboVert.uploadData(SIZE_OF_VERTEX * MAX_VERTICES_IN_BATCH,GL_STREAM_DRAW);
  vboCol.bind();
  vboCol.uploadData(SIZE_OF_COLOR * MAX_VERTICES_IN_BATCH,GL_STREAM_DRAW);
  vboTex.bind();
  vboTex.uploadData(SIZE_OF_TEXCOORD * MAX_VERTICES_IN_BATCH,GL_STREAM_DRAW);
  vboNorm.bind();
  vboNorm.uploadData(SIZE_OF_NORMAL * MAX_VERTICES_IN_BATCH,GL_STREAM_DRAW);
}
Program: 97009
Project: 97009
Buggy source:
/** 
 * Uploads the data collected to the OpenGL buffers.
 */
private void uploadData(){
  vboVert.bind();
  vboVert.uploadSubData(vBuffer,0);
  vao.pointAttribute(0,4,GL_FLOAT,vboVert);
  vboCol.bind();
  vboCol.uploadSubData(cBuffer,0);
  vao.pointAttribute(1,4,GL_FLOAT,vboCol);
  vboTex.bind();
  vboTex.uploadSubData(tBuffer,0);
  vao.pointAttribute(2,2,GL_FLOAT,vboTex);
}

Fixed version (ground truth):
/** 
 * Uploads the data collected to the OpenGL buffers.
 */
private void uploadData(){
  vboVert.bind();
  vboVert.uploadSubData(vBuffer,0);
  vao.pointAttribute(vertexLocation,4,GL_FLOAT,vboVert);
  vboCol.bind();
  vboCol.uploadSubData(cBuffer,0);
  vao.pointAttribute(colorLocation,4,GL_FLOAT,vboCol);
  vboTex.bind();
  vboTex.uploadSubData(tBuffer,0);
  vao.pointAttribute(texCoordLocation,2,GL_FLOAT,vboTex);
  vboNorm.bind();
  vboNorm.uploadSubData(nBuffer,0);
  vao.pointAttribute(normalLocation,4,GL_FLOAT,vboNorm);
}
Program: 97010
Project: 97010
Buggy source:
/** 
 * Flushes the data collected to the GPU.
 */
public void flush(){
  if (vertexCount == 0)   return;
  fillBuffers();
  Program.CURRENT.setupUniforms();
  vBuffer.flip();
  cBuffer.flip();
  tBuffer.flip();
  vao.bind();
  vao.enableAttributeArray(0);
  vao.enableAttributeArray(1);
  vao.enableAttributeArray(2);
  uploadData();
  glDrawArrays(beginMode.getGlPrimitive(),0,vertexCount);
  GLError.check();
  vao.disableAttributeArray(0);
  vao.disableAttributeArray(1);
  vao.disableAttributeArray(2);
  glBindVertexArray(0);
  GLError.check();
  vBuffer.clear();
  cBuffer.clear();
  tBuffer.clear();
  vertexCount=0;
  colorCount=0;
  texCoordCount=0;
}

Fixed version (ground truth):
/** 
 * Flushes the data collected to the GPU.
 */
public void flush(){
  if (vertexCount == 0)   return;
  fillBuffers();
  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);
  uploadData();
  glDrawArrays(beginMode.getGlPrimitive(),0,vertexCount);
  GLError.check();
  vao.disableAttributeArray(vertexLocation);
  vao.disableAttributeArray(colorLocation);
  vao.disableAttributeArray(texCoordLocation);
  vao.disableAttributeArray(normalLocation);
  glBindVertexArray(0);
  GLError.check();
  vBuffer.clear();
  cBuffer.clear();
  tBuffer.clear();
  nBuffer.clear();
  vertexCount=0;
  colorCount=0;
  texCoordCount=0;
  normalCount=0;
}
Program: 97011
Project: 97011
Buggy source:
/** 
 * Creates the Batcher, and initialises OpenGL
 */
public Batcher(){
  vBuffer=BufferUtils.createFloatBuffer(SIZE_OF_VERTEX * MAX_VERTICES_IN_BATCH);
  cBuffer=BufferUtils.createFloatBuffer(SIZE_OF_COLOR * MAX_VERTICES_IN_BATCH);
  tBuffer=BufferUtils.createFloatBuffer(SIZE_OF_TEXCOORD * MAX_VERTICES_IN_BATCH);
  transform=new Transform();
  initGLHandles();
}

Fixed version (ground truth):
/** 
 * Creates the Batcher, and initialises OpenGL
 */
public Batcher(){
  vBuffer=BufferUtils.createFloatBuffer(SIZE_OF_VERTEX * MAX_VERTICES_IN_BATCH);
  cBuffer=BufferUtils.createFloatBuffer(SIZE_OF_COLOR * MAX_VERTICES_IN_BATCH);
  tBuffer=BufferUtils.createFloatBuffer(SIZE_OF_TEXCOORD * MAX_VERTICES_IN_BATCH);
  nBuffer=BufferUtils.createFloatBuffer(SIZE_OF_NORMAL * MAX_VERTICES_IN_BATCH);
  transform=new Transform();
  initGLHandles();
}
Program: 97012
Project: 97012
Buggy source:
private void fillBuffers(){
  Color col=texCoordCount == vertexCount ? Color.TRANSPARENT : Color.WHITE;
  while (colorCount < vertexCount) {
    cBuffer.put(col.getR()).put(col.getG()).put(col.getB()).put(col.getA());
    colorCount++;
  }
  while (texCoordCount < vertexCount) {
    tBuffer.put(0).put(0);
    texCoordCount++;
  }
}

Fixed version (ground truth):
private void fillBuffers(){
  Color col=texCoordCount == vertexCount ? Color.TRANSPARENT : Color.WHITE;
  while (colorCount < vertexCount) {
    cBuffer.put(col.getR()).put(col.getG()).put(col.getB()).put(col.getA());
    colorCount++;
  }
  while (texCoordCount < vertexCount) {
    tBuffer.put(0).put(0);
    texCoordCount++;
  }
  while (normalCount < vertexCount) {
    nBuffer.put(0).put(0).put(0).put(0);
    normalCount++;
  }
}
Program: 97013
Project: 97013
Buggy source:
public void drawString(Batcher b,String text,float x,float y,Color col){
  Texture current=Texture.CURRENT;
  b.begin();
{
    fontTexture.bind();
    float startX=x;
    for (    char ch : text.toCharArray()) {
      FontChar c=chars[(int)ch];
      if (ch == '\n') {
        y+=fontMetrics.getHeight();
        x=startX;
        continue;
      }
      float minU=c.x / fontTexture.getWidth();
      float maxU=(c.x + c.w + 2) / fontTexture.getWidth();
      float minV=c.y / fontTexture.getHeight();
      float maxV=(c.y + c.h) / fontTexture.getHeight();
      b.drawTexture2d(fontTexture.getSubTexture(minU,minV,maxU,maxV),new Vector2(x,y),col);
      x+=c.w;
    }
  }
  b.end();
  current.bind();
}

Fixed version (ground truth):
public void drawString(Batcher b,String text,float x,float y,Color col){
  Texture current=Texture.CURRENT;
  b.begin();
{
    fontTexture.bind();
    float startX=x;
    for (    char ch : text.toCharArray()) {
      FontChar c=chars[(int)ch];
      if (ch == '\n') {
        y+=fontMetrics.getHeight();
        x=startX;
        continue;
      }
      float minU=c.x / fontTexture.getWidth();
      float maxU=(c.x + c.w) / fontTexture.getWidth();
      float minV=c.y / fontTexture.getHeight();
      float maxV=(c.y + c.h) / fontTexture.getHeight();
      b.drawTexture2d(fontTexture.getSubTexture(minU,minV,maxU,maxV),new Vector2(x,y),col);
      x+=c.w;
    }
  }
  b.end();
  current.bind();
}
Program: 97014
Project: 97014
Buggy source:
public void use(){
  if (CURRENT == this)   return;
  if (disposed)   throw new GLException("String_Node_Str");
  glUseProgram(id);
  GLError.check();
  CURRENT=this;
  setupUniforms();
}

Fixed version (ground truth):
public void use(){
  if (CURRENT == this)   return;
  if (disposed)   throw new GLException("String_Node_Str");
  glUseProgram(id);
  GLError.check();
  CURRENT=this;
  prepareFrame();
}
Program: 97015
Project: 97015
Buggy source:
public static void init(){
  transform=new Transform();
  children=new ArrayList<>();
}

Fixed version (ground truth):
public static void init(){
  transform=new Transform();
  children=new ArrayList<>();
  Program.CURRENT=null;
  Texture.CURRENT=null;
  Program.DEFAULT.use();
  Texture.EMPTY.bind();
}
Program: 97016
Project: 97016
Buggy source:
public Circle(float x,float y,float radius){
  this.x=x;
  this.y=y;
  this.radius=radius;
}

Fixed version (ground truth):
public Circle(float x,float y,float radius){
  this.x=x;
  this.y=y;
  this.radius=radius;
  setPosition(new Vector2(x,y));
  updateVertices();
}
Program: 97017
Project: 97017
Buggy source:
public void setY(float y){
  this.y=y;
}

Fixed version (ground truth):
public void setY(float y){
  this.y=y;
  setPosition(new Vector2(x,y));
}
Program: 97018
Project: 97018
Buggy source:
public void setX(float x){
  this.x=x;
}

Fixed version (ground truth):
public void setX(float x){
  this.x=x;
  setPosition(new Vector2(x,y));
}
Program: 97019
Project: 97019
Buggy source:
public boolean intersects(Circle c){
  return (x * c.x + y * c.y) <= (radius + c.radius) * (radius + c.radius);
}

Fixed version (ground truth):
public boolean intersects(Polygon p){
  if (p instanceof Circle) {
    Circle c=(Circle)p;
    return (((x - c.x) * (x - c.x)) + ((y - c.y) * (y - c.y))) < (radius + c.radius) * (radius + c.radius);
  }
 else   return super.intersects(p);
}
Program: 97020
Project: 97020
Buggy source:
public void setRadius(float radius){
  this.radius=radius;
}

Fixed version (ground truth):
public void setRadius(float radius){
  this.radius=radius;
  updateVertices();
}
Program: 97021
Project: 97021
Buggy source:
public void setY(float y){
  this.y=y;
}

Fixed version (ground truth):
public void setY(float y){
  this.y=y;
  setPosition(new Vector2(x,y));
}
Program: 97022
Project: 97022
Buggy source:
public void setX(float x){
  this.x=x;
}

Fixed version (ground truth):
public void setX(float x){
  this.x=x;
  setPosition(new Vector2(x,y));
}
Program: 97023
Project: 97023
Buggy source:
public boolean intersects(Rectangle r){
  return (x < r.x + r.width) && (r.x < x + width) && (y < r.y + r.height)&& (r.y < y + height);
}

Fixed version (ground truth):
public boolean intersects(Polygon p){
  if (p instanceof Rectangle) {
    Rectangle r=(Rectangle)p;
    return (x < r.x + r.width) && (r.x < x + width) && (y < r.y + r.height)&& (r.y < y + height);
  }
 else   return super.intersects(p);
}
Program: 97024
Project: 97024
Buggy source:
public Rectangle(float x,float y,float width,float height){
  this.x=x;
  this.y=y;
  this.width=width;
  this.height=height;
}

Fixed version (ground truth):
public Rectangle(float x,float y,float width,float height){
  this.x=x;
  this.y=y;
  this.width=width;
  this.height=height;
  setPosition(new Vector2(x,y));
  updateVertices();
}
Program: 97025
Project: 97025
Buggy source:
public void setWidth(float width){
  this.width=width;
}

Fixed version (ground truth):
public void setWidth(float width){
  this.width=width;
  updateVertices();
}
Program: 97026
Project: 97026
Buggy source:
public void setHeight(float height){
  this.height=height;
}

Fixed version (ground truth):
public void setHeight(float height){
  this.height=height;
  updateVertices();
}
Program: 97027
Project: 97027
Buggy source:
@Override public boolean equals(Object o){
  if (this == o)   return true;
  if (o == null || getClass() != o.getClass())   return false;
  Entity2D entity2D=(Entity2D)o;
  if (!polygon.equals(entity2D.polygon))   return false;
  if (!position.equals(entity2D.position))   return false;
  if (!velocity.equals(entity2D.velocity))   return false;
  return true;
}

Fixed version (ground truth):
@Override public boolean equals(Object o){
  if (this == o)   return true;
  if (o == null || getClass() != o.getClass())   return false;
  Entity2D entity2D=(Entity2D)o;
  return polygon.equals(entity2D.polygon) && position.equals(entity2D.position) && velocity.equals(entity2D.velocity);
}
Program: 97028
Project: 97028
Buggy source:
public Circle(float x,float y,float radius){
  this.radius=radius;
  setCenter(new Vector2(x,y));
  updateVertices();
}

Fixed version (ground truth):
public Circle(float x,float y,float radius){
  this.radius=radius;
  updateVertices();
  setCenter(new Vector2(x,y));
}