nus-yam/ex-repair huggingface dataset:
Program: 109199
Project: 109199
Buggy source:
/** 
 * Add a shape to the name lookup table.
 */
protected void addName(String nom,PShape shape){
  if (parent != null) {
    parent.addName(nom,shape);
  }
 else {
    if (nameTable == null) {
      nameTable=new HashMap<String,PShape>();
    }
    nameTable.put(nom,shape);
  }
}

Fixed version (ground truth):
/** 
 * Add a shape to the name lookup table.
 */
public void addName(String nom,PShape shape){
  if (parent != null) {
    parent.addName(nom,shape);
  }
 else {
    if (nameTable == null) {
      nameTable=new HashMap<String,PShape>();
    }
    nameTable.put(nom,shape);
  }
}
Program: 109200
Project: 109200
Buggy source:
/** 
 * Add a shape to the name lookup table.
 */
protected void addName(String nom,PShape shape){
  if (nameTable == null) {
    nameTable=new HashMap<String,PShape>();
  }
  nameTable.put(nom,shape);
}

Fixed version (ground truth):
/** 
 * Add a shape to the name lookup table.
 */
public void addName(String nom,PShape shape){
  if (nameTable == null) {
    nameTable=new HashMap<String,PShape>();
  }
  nameTable.put(nom,shape);
}
Program: 109201
Project: 109201
Buggy source:
public PShape groupChildren(PShape[] gchildren,String gname){
  if (family != GROUP)   return null;
  PShape3D group=new PShape3D();
  group.family=PShape.GROUP;
  group.name=gname;
  group.papplet=papplet;
  group.a3d=a3d;
  group.gl=gl;
  group.root=root;
  PShape child, p;
  int idx;
  child=gchildren[0];
  p=child.parent;
  if (p != null) {
    idx=p.getChildIdx(child);
    if (idx < 0)     idx=0;
  }
 else {
    p=this;
    idx=0;
  }
  p.addChild(group,idx);
  for (int i=0; i < gchildren.length; i++) {
    child=gchildren[i];
    p=child.parent;
    if (p != null) {
      idx=p.getChildIdx(child);
      if (-1 < idx) {
        p.removeChild(idx);
      }
    }
  }
  group.firstVertex=root.vertexCount;
  group.lastVertex=0;
  for (int i=0; i < gchildren.length; i++) {
    group.firstVertex=PApplet.min(group.firstVertex,((PShape3D)gchildren[i]).firstVertex);
    group.lastVertex=PApplet.max(group.lastVertex,((PShape3D)gchildren[i]).lastVertex);
  }
  for (int i=0; i < gchildren.length; i++) {
    group.addChildImpl(gchildren[i],false);
  }
  return group;
}

Fixed version (ground truth):
public PShape groupChildren(PShape[] gchildren,String gname){
  if (family != GROUP)   return null;
  PShape3D group=new PShape3D();
  group.family=PShape.GROUP;
  group.name=gname;
  group.papplet=papplet;
  group.a3d=a3d;
  group.gl=gl;
  group.root=root;
  PShape child, p;
  int idx;
  child=gchildren[0];
  p=child.parent;
  if (p != null) {
    idx=p.getChildIndex(child);
    if (idx < 0)     idx=0;
  }
 else {
    p=this;
    idx=0;
  }
  p.addChild(group,idx);
  for (int i=0; i < gchildren.length; i++) {
    child=gchildren[i];
    p=child.parent;
    if (p != null) {
      idx=p.getChildIndex(child);
      if (-1 < idx) {
        p.removeChild(idx);
      }
    }
  }
  group.firstVertex=root.vertexCount;
  group.lastVertex=0;
  for (int i=0; i < gchildren.length; i++) {
    group.firstVertex=PApplet.min(group.firstVertex,((PShape3D)gchildren[i]).firstVertex);
    group.lastVertex=PApplet.max(group.lastVertex,((PShape3D)gchildren[i]).lastVertex);
  }
  for (int i=0; i < gchildren.length; i++) {
    group.addChildImpl(gchildren[i],false);
  }
  return group;
}
Program: 109203
Project: 109203
Buggy source:
/** 
 * First try to create a default font, but if that's not possible, throw   an exception that halts the program because textFont() has not been used  prior to the specified method.
 */
protected void defaultFontOrDeath(String method,float size){
  if (parent != null) {
    textFont=parent.createDefaultFont(size);
  }
 else {
    throw new RuntimeException("String_Node_Str" + method + "String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * First try to create a default font, but if that's not possible, throw an exception that halts the program because textFont() has not been used prior to the specified method.
 */
protected void defaultFontOrDeath(String method,float size){
  if (parent != null) {
    textFont=parent.createDefaultFont(size);
  }
 else {
    throw new RuntimeException("String_Node_Str" + method + "String_Node_Str");
  }
}
Program: 109204
Project: 109204
Buggy source:
/** 
 * This utility method creates a texture for the provided image, and adds it to the metadata cache of the image.
 * @param img the image to have a texture metadata associated to it
 */
protected PTexture addTexture(PImage img){
  PTexture.Parameters params=(PTexture.Parameters)img.getParams(a3d);
  if (params == null) {
    params=PTexture.newParameters();
    img.setParams(a3d,params);
  }
  PTexture tex=new PTexture(img.parent,img.width,img.height,params);
  img.loadPixels();
  tex.set(img.pixels);
  img.setCache(a3d,tex);
  return tex;
}

Fixed version (ground truth):
/** 
 * This utility method creates a texture for the provided image, and adds it to the metadata cache of the image.
 * @param img the image to have a texture metadata associated to it
 */
protected PTexture addTexture(PImage img){
  PTexture.Parameters params=(PTexture.Parameters)img.getParams(a3d);
  if (params == null) {
    params=PTexture.newParameters();
    img.setParams(a3d,params);
  }
  PTexture tex=new PTexture(img.parent,img.width,img.height,params);
  if (img.pixels == null) {
    img.loadPixels();
  }
  tex.set(img.pixels);
  img.setCache(a3d,tex);
  return tex;
}
Program: 109206
Project: 109206
Buggy source:
static final public String hex(int what,int digits){
  String stuff=Integer.toHexString(what).toUpperCase();
  int length=stuff.length();
  if (length > digits) {
    return stuff.substring(length - digits);
  }
 else   if (length < digits) {
    return "String_Node_Str".substring(8 - (digits - length)) + stuff;
  }
  return stuff;
}

Fixed version (ground truth):
/** 
 * Format an integer as a hex string using the specified number of digits.
 * @param what the value to format
 * @param digits the number of digits (maximum 8)
 * @return a String object with the formatted values
 */
static final public String hex(int what,int digits){
  String stuff=Integer.toHexString(what).toUpperCase();
  if (digits > 8) {
    digits=8;
  }
  int length=stuff.length();
  if (length > digits) {
    return stuff.substring(length - digits);
  }
 else   if (length < digits) {
    return "String_Node_Str".substring(8 - (digits - length)) + stuff;
  }
  return stuff;
}
Program: 109207
Project: 109207
Buggy source:
/** 
 * Returns a String that contains the binary value of an int. The digits parameter determines how many digits will be used.
 */
static final public String binary(int what,int digits){
  String stuff=Integer.toBinaryString(what);
  int length=stuff.length();
  if (length > digits) {
    return stuff.substring(length - digits);
  }
 else   if (length < digits) {
    int offset=32 - (digits - length);
    return "String_Node_Str".substring(offset) + stuff;
  }
  return stuff;
}

Fixed version (ground truth):
/** 
 * Returns a String that contains the binary value of an int. The digits parameter determines how many digits will be used.
 */
static final public String binary(int what,int digits){
  String stuff=Integer.toBinaryString(what);
  if (digits > 32) {
    digits=32;
  }
  int length=stuff.length();
  if (length > digits) {
    return stuff.substring(length - digits);
  }
 else   if (length < digits) {
    int offset=32 - (digits - length);
    return "String_Node_Str".substring(offset) + stuff;
  }
  return stuff;
}
Program: 109211
Project: 109211
Buggy source:
protected void addDefaultChild(){
  PShape child=createChild("String_Node_Str",0,vertexCount - 1,glMode,0,null);
  addChild(child);
}

Fixed version (ground truth):
protected void addDefaultChild(){
  PShape child=createChild("String_Node_Str",0,vertexCount - 1,getDrawModeImpl(),0,null);
  addChild(child);
}
Program: 109212
Project: 109212
Buggy source:
protected void copyToTexture(IntBuffer buffer,int glid,int gltarget){
  gl.glEnable(gltarget);
  gl.glBindTexture(gltarget,glid);
  gl.glTexSubImage2D(gltarget,0,0,0,width,height,GL10.GL_RGBA,GL10.GL_UNSIGNED_BYTE,buffer);
  gl.glDisable(gltarget);
}

Fixed version (ground truth):
protected void copyToTexture(IntBuffer buffer,int glid,int gltarget){
  gl.glEnable(gltarget);
  gl.glBindTexture(gltarget,glid);
  gl.glTexSubImage2D(gltarget,0,0,0,width,height,GL10.GL_RGBA,GL10.GL_UNSIGNED_BYTE,buffer);
  gl.glBindTexture(gltarget,0);
  gl.glDisable(gltarget);
}
Program: 109213
Project: 109213
Buggy source:
protected void clearMultitextureBlend(int num){
  for (int i=0; i < num; i++) {
    gl11.glActiveTexture(GL11.GL_TEXTURE0 + i);
    gl11.glTexEnvi(GL11.GL_TEXTURE_ENV,GL11.GL_TEXTURE_ENV_MODE,GL11.GL_MODULATE);
  }
}

Fixed version (ground truth):
protected void clearMultitextureBlend(int num){
  for (int i=0; i < num; i++) {
    gl11.glActiveTexture(GL11.GL_TEXTURE0 + i);
    gl11.glTexEnvi(GL11.GL_TEXTURE_ENV,GL11.GL_TEXTURE_ENV_MODE,GL11.GL_MODULATE);
  }
  if (blend) {
    blend(blendMode);
  }
 else {
    noBlend();
  }
}
Program: 109215
Project: 109215
Buggy source:
protected void drawTexture(PTexture tex,int[] crop,int x,int y,int w,int h){
  gl.glEnable(tex.getGLTarget());
  gl.glBindTexture(tex.getGLTarget(),tex.getGLID());
  gl.glDepthMask(false);
  gl.glDisable(GL10.GL_BLEND);
  gl.glTexEnvf(GL10.GL_TEXTURE_ENV,GL10.GL_TEXTURE_ENV_MODE,GL10.GL_REPLACE);
  gl11.glTexParameteriv(GL10.GL_TEXTURE_2D,GL11Ext.GL_TEXTURE_CROP_RECT_OES,crop,0);
  gl11x.glDrawTexiOES(x,y,0,w,h);
  gl.glTexEnvf(GL10.GL_TEXTURE_ENV,GL10.GL_TEXTURE_ENV_MODE,GL10.GL_MODULATE);
  gl.glDisable(tex.getGLTarget());
  if (hints[DISABLE_DEPTH_MASK]) {
    gl.glDepthMask(false);
  }
 else {
    gl.glDepthMask(true);
  }
  if (blend) {
    blend(blendMode);
  }
 else {
    noBlend();
  }
}

Fixed version (ground truth):
protected void drawTexture(PTexture tex,int[] crop,int x,int y,int w,int h){
  gl.glEnable(tex.getGLTarget());
  gl.glBindTexture(tex.getGLTarget(),tex.getGLID());
  gl.glDepthMask(false);
  gl.glDisable(GL10.GL_BLEND);
  gl.glTexEnvf(GL10.GL_TEXTURE_ENV,GL10.GL_TEXTURE_ENV_MODE,GL10.GL_REPLACE);
  gl11.glTexParameteriv(GL10.GL_TEXTURE_2D,GL11Ext.GL_TEXTURE_CROP_RECT_OES,crop,0);
  gl11x.glDrawTexiOES(x,y,0,w,h);
  gl.glTexEnvf(GL10.GL_TEXTURE_ENV,GL10.GL_TEXTURE_ENV_MODE,GL10.GL_MODULATE);
  gl.glBindTexture(tex.getGLTarget(),0);
  gl.glDisable(tex.getGLTarget());
  if (hints[DISABLE_DEPTH_MASK]) {
    gl.glDepthMask(false);
  }
 else {
    gl.glDepthMask(true);
  }
  if (blend) {
    blend(blendMode);
  }
 else {
    noBlend();
  }
}
Program: 109216
Project: 109216
Buggy source:
protected void copyToTexture(PTexture tex,IntBuffer buffer,int x,int y,int w,int h){
  gl.glEnable(tex.getGLTarget());
  gl.glBindTexture(tex.getGLTarget(),tex.getGLID());
  gl.glTexSubImage2D(tex.getGLTarget(),0,x,y,w,h,GL10.GL_RGBA,GL10.GL_UNSIGNED_BYTE,buffer);
  gl.glDisable(tex.getGLTarget());
}

Fixed version (ground truth):
protected void copyToTexture(PTexture tex,IntBuffer buffer,int x,int y,int w,int h){
  gl.glEnable(tex.getGLTarget());
  gl.glBindTexture(tex.getGLTarget(),tex.getGLID());
  gl.glTexSubImage2D(tex.getGLTarget(),0,x,y,w,h,GL10.GL_RGBA,GL10.GL_UNSIGNED_BYTE,buffer);
  gl.glBindTexture(tex.getGLTarget(),0);
  gl.glDisable(tex.getGLTarget());
}
Program: 109218
Project: 109218
Buggy source:
protected void addNewFace(boolean firstFace,PImage[] images){
  if (faceCount == faceOffset.length) {
    faceOffset=PApplet.expand(faceOffset);
    faceLength=PApplet.expand(faceLength);
    PImage tempi[][]=new PImage[faceCount << 1][MAX_TEXTURES];
    PApplet.arrayCopy(faceTextures,0,tempi,0,faceCount);
    faceTextures=tempi;
  }
  faceOffset[faceCount]=firstFace ? 0 : triangleCount;
  faceLength[faceCount]=1;
  PImage p[]=faceTextures[faceCount];
  if (1 < numMultitextures) {
    PApplet.arrayCopy(images,0,p,0,numMultitextures);
  }
  if (0 < numMultitextures) {
    p[0]=images[0];
  }
 else {
    p[0]=null;
  }
  faceCount++;
}

Fixed version (ground truth):
protected void addNewFace(boolean firstFace,PImage[] images){
  if (faceCount == faceOffset.length) {
    faceOffset=PApplet.expand(faceOffset);
    faceLength=PApplet.expand(faceLength);
    PImage tempi[][]=new PImage[faceCount << 1][MAX_TEXTURES];
    PApplet.arrayCopy(faceTextures,0,tempi,0,faceCount);
    faceTextures=tempi;
  }
  faceOffset[faceCount]=firstFace ? 0 : triangleCount;
  faceLength[faceCount]=1;
  PImage p[]=faceTextures[faceCount];
  if (1 < numMultitextures) {
    PApplet.arrayCopy(images,0,p,0,numMultitextures);
  }
  if (0 < numMultitextures) {
    p[0]=images[0];
  }
 else {
    p[0]=null;
  }
  java.util.Arrays.fill(p,numMultitextures,maxTextureUnits,null);
  faceCount++;
}
Program: 109221
Project: 109221
Buggy source:
protected void loadTexcoords(int unit,int first,int last){
  if (last < first || first < 0 || vertexCount <= last) {
    PGraphics.showWarning("String_Node_Str");
    updateElement=-1;
    return;
  }
  if (updateElement != -1) {
    PGraphics.showWarning("String_Node_Str");
    return;
  }
  if (PGraphicsAndroid3D.maxTextureUnits <= unit) {
    PGraphics.showWarning("String_Node_Str");
    return;
  }
  updateElement=TEXCOORDS;
  firstUpdateIdx=first;
  lastUpdateIdx=last;
  if (numTexBuffers <= unit) {
    addTexBuffers(unit - numTexBuffers + 1);
  }
  gl.glBindBuffer(GL11.GL_ARRAY_BUFFER,glTexCoordBufferID[unit]);
  int offset=first * 2;
  int size=(last - first + 1) * 2;
  texCoordBuffer.limit(texCoordBuffer.capacity());
  texCoordBuffer.rewind();
  texCoordBuffer.get(texcoords,offset,size);
  updateTexunit=unit;
}

Fixed version (ground truth):
protected void loadTexcoords(int unit,int first,int last){
  if (last < first || first < 0 || vertexCount <= last) {
    PGraphics.showWarning("String_Node_Str");
    updateElement=-1;
    return;
  }
  if (updateElement != -1) {
    PGraphics.showWarning("String_Node_Str");
    return;
  }
  if (PGraphicsAndroid3D.maxTextureUnits <= unit) {
    PGraphics.showWarning("String_Node_Str");
    return;
  }
  updateElement=TEXCOORDS;
  firstUpdateIdx=first;
  lastUpdateIdx=last;
  if (numTexBuffers <= unit) {
    addTexBuffers(unit - numTexBuffers + 1);
  }
  gl.glBindBuffer(GL11.GL_ARRAY_BUFFER,glTexCoordBufferID[unit]);
  int offset=first * 2;
  int size=(last - first + 1) * 2;
  texCoordBuffer.limit(texCoordBuffer.capacity());
  texCoordBuffer.rewind();
  texCoordBuffer.get(texcoords,offset,size);
  normalizeTexcoords(unit);
  updateTexunit=unit;
}
Program: 109222
Project: 109222
Buggy source:
public void updateTexcoords(){
  if (updateElement == TEXCOORDS) {
    int offset=firstUpdateIdx * 2;
    int size=(lastUpdateIdx - firstUpdateIdx + 1) * 2;
    texCoordBuffer.position(0);
    texCoordBuffer.put(texcoords,offset,size);
    texCoordBuffer.flip();
    gl.glBufferSubData(GL11.GL_ARRAY_BUFFER,offset * PGraphicsAndroid3D.SIZEOF_FLOAT,size * PGraphicsAndroid3D.SIZEOF_FLOAT,texCoordBuffer);
    gl.glBindBuffer(GL11.GL_ARRAY_BUFFER,0);
    texCoordSet[updateTexunit]=true;
    updateElement=-1;
  }
 else {
    PGraphics.showWarning("String_Node_Str");
  }
}

Fixed version (ground truth):
public void updateTexcoords(){
  if (updateElement == TEXCOORDS) {
    int offset=firstUpdateIdx * 2;
    int size=(lastUpdateIdx - firstUpdateIdx + 1) * 2;
    unnormalizeTexcoords(updateTexunit);
    texCoordBuffer.position(0);
    texCoordBuffer.put(texcoords,offset,size);
    texCoordBuffer.flip();
    gl.glBufferSubData(GL11.GL_ARRAY_BUFFER,offset * PGraphicsAndroid3D.SIZEOF_FLOAT,size * PGraphicsAndroid3D.SIZEOF_FLOAT,texCoordBuffer);
    gl.glBindBuffer(GL11.GL_ARRAY_BUFFER,0);
    texCoordSet[updateTexunit]=true;
    updateElement=-1;
  }
 else {
    PGraphics.showWarning("String_Node_Str");
  }
}
Program: 109223
Project: 109223
Buggy source:
/** 
 * Creates the opengl texture object.
 * @param w int
 * @param h int  
 */
protected void createTexture(int w,int h){
  deleteTexture();
  if (PGraphicsAndroid3D.npotTexSupported) {
    glWidth=w;
    glHeight=h;
  }
 else {
    glWidth=nextPowerOfTwo(w);
    glHeight=nextPowerOfTwo(h);
  }
  if ((glWidth > PGraphicsAndroid3D.maxTextureSize) || (glHeight > PGraphicsAndroid3D.maxTextureSize)) {
    glWidth=glHeight=0;
    throw new RuntimeException("String_Node_Str" + "String_Node_Str" + PGraphicsAndroid3D.maxTextureSize + "String_Node_Str");
  }
  usingMipmaps=((glMinFilter == GL10.GL_NEAREST_MIPMAP_NEAREST) || (glMinFilter == GL10.GL_LINEAR_MIPMAP_NEAREST) || (glMinFilter == GL10.GL_NEAREST_MIPMAP_LINEAR)|| (glMinFilter == GL10.GL_LINEAR_MIPMAP_LINEAR));
  gl.glEnable(glTarget);
  glID=a3d.createGLResource(PGraphicsAndroid3D.GL_TEXTURE_OBJECT);
  gl.glBindTexture(glTarget,glID);
  gl.glTexParameterf(glTarget,GL10.GL_TEXTURE_MIN_FILTER,glMinFilter);
  gl.glTexParameterf(glTarget,GL10.GL_TEXTURE_MAG_FILTER,glMagFilter);
  gl.glTexParameterf(glTarget,GL10.GL_TEXTURE_WRAP_S,glWrapS);
  gl.glTexParameterf(glTarget,GL10.GL_TEXTURE_WRAP_T,glWrapT);
  gl.glTexImage2D(glTarget,0,glFormat,glWidth,glHeight,0,GL10.GL_RGBA,GL10.GL_UNSIGNED_BYTE,null);
  gl.glDisable(glTarget);
  flippedX=false;
  flippedY=false;
  maxTexCoordU=(float)w / glWidth;
  maxTexCoordV=(float)h / glHeight;
}

Fixed version (ground truth):
/** 
 * Creates the opengl texture object.
 * @param w int
 * @param h int  
 */
protected void createTexture(int w,int h){
  deleteTexture();
  if (PGraphicsAndroid3D.npotTexSupported) {
    glWidth=w;
    glHeight=h;
  }
 else {
    glWidth=nextPowerOfTwo(w);
    glHeight=nextPowerOfTwo(h);
  }
  if ((glWidth > PGraphicsAndroid3D.maxTextureSize) || (glHeight > PGraphicsAndroid3D.maxTextureSize)) {
    glWidth=glHeight=0;
    throw new RuntimeException("String_Node_Str" + "String_Node_Str" + PGraphicsAndroid3D.maxTextureSize + "String_Node_Str");
  }
  usingMipmaps=((glMinFilter == GL10.GL_NEAREST_MIPMAP_NEAREST) || (glMinFilter == GL10.GL_LINEAR_MIPMAP_NEAREST) || (glMinFilter == GL10.GL_NEAREST_MIPMAP_LINEAR)|| (glMinFilter == GL10.GL_LINEAR_MIPMAP_LINEAR));
  gl.glEnable(glTarget);
  glID=a3d.createGLResource(PGraphicsAndroid3D.GL_TEXTURE_OBJECT);
  gl.glBindTexture(glTarget,glID);
  gl.glTexParameterf(glTarget,GL10.GL_TEXTURE_MIN_FILTER,glMinFilter);
  gl.glTexParameterf(glTarget,GL10.GL_TEXTURE_MAG_FILTER,glMagFilter);
  gl.glTexParameterf(glTarget,GL10.GL_TEXTURE_WRAP_S,glWrapS);
  gl.glTexParameterf(glTarget,GL10.GL_TEXTURE_WRAP_T,glWrapT);
  gl.glTexImage2D(glTarget,0,glFormat,glWidth,glHeight,0,GL10.GL_RGBA,GL10.GL_UNSIGNED_BYTE,null);
  gl.glBindTexture(glTarget,0);
  gl.glDisable(glTarget);
  flippedX=false;
  flippedY=false;
  maxTexCoordU=(float)w / glWidth;
  maxTexCoordV=(float)h / glHeight;
}
Program: 109224
Project: 109224
Buggy source:
/** 
 * Sets the texture as flipped or not flipped on the vertical direction.
 * @param v boolean;
 */
protected void setFlippedY(boolean v){
  flippedY=v;
}

Fixed version (ground truth):
/** 
 * Sets the texture as flipped or not flipped on the vertical direction.
 * @param v boolean;
 */
public void setFlippedY(boolean v){
  flippedY=v;
}
Program: 109225
Project: 109225
Buggy source:
public void addChild(PShape who){
  if (family == GROUP) {
    super.addChild(who);
    PShape3D who3d=(PShape3D)who;
    who3d.papplet=papplet;
    who3d.a3d=a3d;
    who3d.gl=gl;
    for (int n=who3d.firstVertex; n < who3d.lastVertex; n++) {
      vertexChild[n]=who3d;
    }
  }
 else {
    PGraphics.showWarning("String_Node_Str");
  }
}

Fixed version (ground truth):
public void addChild(PShape who){
  if (family == GROUP) {
    super.addChild(who);
    PShape3D who3d=(PShape3D)who;
    who3d.papplet=papplet;
    who3d.a3d=a3d;
    who3d.gl=gl;
    for (int n=who3d.firstVertex; n <= who3d.lastVertex; n++) {
      vertexChild[n]=who3d;
    }
  }
 else {
    PGraphics.showWarning("String_Node_Str");
  }
}
Program: 109226
Project: 109226
Buggy source:
/** 
 * Similar to gluPerspective(). Implementation based on Mesa's glu.c
 */
public void perspective(float fov,float aspect,float zNear,float zFar){
  float ymax=cameraNear * (float)Math.tan(cameraFOV / 2);
  float ymin=-ymax;
  float xmin=ymin * cameraAspect;
  float xmax=ymax * cameraAspect;
  frustum(xmin,xmax,ymin,ymax,cameraNear,cameraFar);
}

Fixed version (ground truth):
/** 
 * Similar to gluPerspective(). Implementation based on Mesa's glu.c
 */
public void perspective(float fov,float aspect,float zNear,float zFar){
  float ymax=zNear * (float)Math.tan(fov / 2);
  float ymin=-ymax;
  float xmin=ymin * aspect;
  float xmax=ymax * aspect;
  frustum(xmin,xmax,ymin,ymax,zNear,zFar);
}
Program: 109229
Project: 109229
Buggy source:
/** 
 * Similar to gluOrtho(), but wipes out the current projection matrix. <P> Implementation partially based on Mesa's matrix.c.
 */
public void ortho(float left,float right,float bottom,float top,float near,float far){
  float x=2.0f / (right - left);
  float y=2.0f / (top - bottom);
  float z=-2.0f / (far - near);
  float tx=-(right + left) / (right - left);
  float ty=-(top + bottom) / (top - bottom);
  float tz=-(far + near) / (far - near);
  glprojection[0]=x;
  glprojection[1]=0.0f;
  glprojection[2]=0.0f;
  glprojection[3]=0.0f;
  glprojection[4]=0.0f;
  glprojection[5]=y;
  glprojection[6]=0.0f;
  glprojection[7]=0.0f;
  glprojection[8]=0;
  glprojection[9]=0;
  glprojection[10]=z;
  glprojection[11]=0.0f;
  glprojection[12]=tx;
  glprojection[13]=ty;
  glprojection[14]=tz;
  glprojection[15]=1.0f;
  gl.glMatrixMode(GL10.GL_PROJECTION);
  gl.glLoadMatrixf(glprojection,0);
  copyGLArrayToPMatrix(glprojection,projection);
  gl.glMatrixMode(GL10.GL_MODELVIEW);
}

Fixed version (ground truth):
/** 
 * Properly setting the ortographic projection depends on the values  used to set the camera (eye and center).
 */
public void ortho(float left,float right,float bottom,float top,float near,float far){
  left-=currentEyeX;
  right-=currentEyeX;
  bottom-=currentCenterY;
  top-=currentCenterY;
  float x=2.0f / (right - left);
  float y=2.0f / (top - bottom);
  float z=-2.0f / (far - near);
  float tx=-(right + left) / (right - left);
  float ty=-(top + bottom) / (top - bottom);
  float tz=-(far + near) / (far - near);
  glprojection[0]=x;
  glprojection[1]=0.0f;
  glprojection[2]=0.0f;
  glprojection[3]=0.0f;
  glprojection[4]=0.0f;
  glprojection[5]=y;
  glprojection[6]=0.0f;
  glprojection[7]=0.0f;
  glprojection[8]=0;
  glprojection[9]=0;
  glprojection[10]=z;
  glprojection[11]=0.0f;
  glprojection[12]=tx;
  glprojection[13]=ty;
  glprojection[14]=tz;
  glprojection[15]=1.0f;
  gl.glMatrixMode(GL10.GL_PROJECTION);
  gl.glLoadMatrixf(glprojection,0);
  copyGLArrayToPMatrix(glprojection,projection);
  gl.glMatrixMode(GL10.GL_MODELVIEW);
}
Program: 109230
Project: 109230
Buggy source:
protected void updatePixelsImpl(int x,int y,int w,int h){
  int x2=x + w;
  int y2=y + h;
  if (!modified) {
    mx1=x;
    mx2=x2;
    my1=y;
    my2=y2;
    modified=true;
  }
 else {
    if (x < mx1)     mx1=x;
    if (x > mx2)     mx2=x;
    if (y < my1)     my1=y;
    if (y > my2)     my2=y;
    if (x2 < mx1)     mx1=x2;
    if (x2 > mx2)     mx2=x2;
    if (y2 < my1)     my1=y2;
    if (y2 > my2)     my2=y2;
  }
}

Fixed version (ground truth):
protected void updatePixelsImpl(int x,int y,int w,int h){
  int x2=x + w;
  int y2=y + h;
  if (!modified) {
    mx1=x;
    mx2=x2;
    my1=y;
    my2=y2;
    modified=true;
  }
 else {
    if (x < mx1)     mx1=x;
    if (x > mx2)     mx2=x;
    if (y < my1)     my1=y;
    if (y > my2)     my2=y;
    if (x2 < mx1)     mx1=x2;
    if (x2 > mx2)     mx2=x2;
    if (y2 < my1)     my1=y2;
    if (y2 > my2)     my2=y2;
  }
  if (texture != null) {
  }
}
Program: 109231
Project: 109231
Buggy source:
/** 
 * Call this when you want to mess with the pixels[] array. <p/> For subclasses where the pixels[] buffer isn't set by default, this should copy all data into the pixels[] array
 */
public void loadPixels(){
  if (pixels == null || pixels.length != width * height) {
    pixels=new int[width * height];
  }
  if (bitmap != null) {
    bitmap.getPixels(pixels,0,width,0,0,width,height);
  }
}

Fixed version (ground truth):
/** 
 * Call this when you want to mess with the pixels[] array. <p/> For subclasses where the pixels[] buffer isn't set by default, this should copy all data into the pixels[] array
 */
public void loadPixels(){
  if (pixels == null || pixels.length != width * height) {
    pixels=new int[width * height];
  }
  if (bitmap != null) {
    bitmap.getPixels(pixels,0,width,0,0,width,height);
  }
  if (texture != null) {
  }
}
Program: 109232
Project: 109232
Buggy source:
static public boolean saveStream(File targetFile,InputStream sourceStream){
  File tempFile=null;
  try {
    File parentDir=targetFile.getParentFile();
    tempFile=File.createTempFile(targetFile.getName(),null,parentDir);
    BufferedInputStream bis=new BufferedInputStream(sourceStream,16384);
    FileOutputStream fos=new FileOutputStream(tempFile);
    BufferedOutputStream bos=new BufferedOutputStream(fos);
    byte[] buffer=new byte[8192];
    int bytesRead;
    while ((bytesRead=bis.read(buffer)) != -1) {
      bos.write(buffer,0,bytesRead);
    }
    bos.flush();
    bos.close();
    bos=null;
    if (!tempFile.renameTo(targetFile)) {
      System.err.println("String_Node_Str" + tempFile.getAbsolutePath());
      return false;
    }
    return true;
  }
 catch (  IOException e) {
    if (tempFile != null) {
      tempFile.delete();
    }
    e.printStackTrace();
    return false;
  }
}

Fixed version (ground truth):
static public boolean saveStream(File targetFile,InputStream sourceStream){
  File tempFile=null;
  try {
    File parentDir=targetFile.getParentFile();
    createPath(targetFile);
    tempFile=File.createTempFile(targetFile.getName(),null,parentDir);
    BufferedInputStream bis=new BufferedInputStream(sourceStream,16384);
    FileOutputStream fos=new FileOutputStream(tempFile);
    BufferedOutputStream bos=new BufferedOutputStream(fos);
    byte[] buffer=new byte[8192];
    int bytesRead;
    while ((bytesRead=bis.read(buffer)) != -1) {
      bos.write(buffer,0,bytesRead);
    }
    bos.flush();
    bos.close();
    bos=null;
    if (!tempFile.renameTo(targetFile)) {
      System.err.println("String_Node_Str" + tempFile.getAbsolutePath());
      return false;
    }
    return true;
  }
 catch (  IOException e) {
    if (tempFile != null) {
      tempFile.delete();
    }
    e.printStackTrace();
    return false;
  }
}
Program: 109233
Project: 109233
Buggy source:
/** 
 * I want to print lines to a file. Why am I always explaining myself? It's the JavaSoft API engineers who need to explain themselves.
 */
static public PrintWriter createWriter(OutputStream output){
  try {
    OutputStreamWriter osw=new OutputStreamWriter(output,"String_Node_Str");
    return new PrintWriter(osw);
  }
 catch (  UnsupportedEncodingException e) {
  }
  return null;
}

Fixed version (ground truth):
/** 
 * I want to print lines to a file. Why am I always explaining myself? It's the JavaSoft API engineers who need to explain themselves.
 */
static public PrintWriter createWriter(OutputStream output){
  try {
    BufferedOutputStream bos=new BufferedOutputStream(output,8192);
    OutputStreamWriter osw=new OutputStreamWriter(bos,"String_Node_Str");
    return new PrintWriter(osw);
  }
 catch (  UnsupportedEncodingException e) {
  }
  return null;
}
Program: 109234
Project: 109234
Buggy source:
/** 
 * Takes a path and creates any in-between folders if they don't already exist. Useful when trying to save to a subfolder that may not actually exist.
 */
static public void createPath(String path){
  try {
    File file=new File(path);
    String parent=file.getParent();
    if (parent != null) {
      File unit=new File(parent);
      if (!unit.exists())       unit.mkdirs();
    }
  }
 catch (  SecurityException se) {
    System.err.println("String_Node_Str" + path);
  }
}

Fixed version (ground truth):
static public void createPath(File file){
  try {
    String parent=file.getParent();
    if (parent != null) {
      File unit=new File(parent);
      if (!unit.exists())       unit.mkdirs();
    }
  }
 catch (  SecurityException se) {
    System.err.println("String_Node_Str" + file.getAbsolutePath());
  }
}
Program: 109235
Project: 109235
Buggy source:
/** 
 * Returns a path inside the applet folder to save to. Like sketchPath(), but creates any in-between folders so that things save properly. <p/> All saveXxxx() functions use the path to the sketch folder, rather than its data folder. Once exported, the data folder will be found inside the jar file of the exported application or applet. In this case, it's not possible to save data into the jar file, because it will often be running from a server, or marked in-use if running from a local file system. With this in mind, saving to the data path doesn't make sense anyway. If you know you're running locally, and want to save to the data folder, use <TT>saveXxxx("data/blah.dat")</TT>.
 */
public String savePath(String where){
  if (where == null)   return null;
  System.out.println("String_Node_Str" + where);
  String filename=sketchPath(where);
  System.out.println("String_Node_Str" + filename);
  createPath(filename);
  return filename;
}

Fixed version (ground truth):
/** 
 * Returns a path inside the applet folder to save to. Like sketchPath(), but creates any in-between folders so that things save properly. <p/> All saveXxxx() functions use the path to the sketch folder, rather than its data folder. Once exported, the data folder will be found inside the jar file of the exported application or applet. In this case, it's not possible to save data into the jar file, because it will often be running from a server, or marked in-use if running from a local file system. With this in mind, saving to the data path doesn't make sense anyway. If you know you're running locally, and want to save to the data folder, use <TT>saveXxxx("data/blah.dat")</TT>.
 */
public String savePath(String where){
  if (where == null)   return null;
  String filename=sketchPath(where);
  createPath(filename);
  return filename;
}
Program: 109236
Project: 109236
Buggy source:
/** 
 * Calculate the angle between two vectors, using the dot product
 * @param v1 a vector
 * @param v2 another vector
 * @return the angle between the vectors
 */
static public float angleBetween(PVector v1,PVector v2){
  float dot=v1.dot(v2);
  float theta=(float)Math.acos(dot / (v1.mag() * v2.mag()));
  return theta;
}

Fixed version (ground truth):
/** 
 * Calculate the angle between two vectors, using the dot product
 * @param v1 a vector
 * @param v2 another vector
 * @return the angle between the vectors
 */
static public float angleBetween(PVector v1,PVector v2){
  double dot=v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
  double v1mag=Math.sqrt(v1.x * v1.x + v1.y * v1.y + v1.z * v1.z);
  double v2mag=Math.sqrt(v2.x * v2.x + v2.y * v2.y + v2.z * v2.z);
  double amt=dot / (v1mag * v2mag);
  if (amt <= -1 || amt >= 1) {
    return PConstants.PI;
  }
  return (float)Math.acos(amt);
}
Program: 109237
Project: 109237
Buggy source:
/** 
 * Returns the value of an attribute.
 * @param name the non-null full name of the attribute.
 * @param defaultValue the default value of the attribute.
 * @return the value, or defaultValue if the attribute does not exist.
 */
public double getDouble(String name,double defaultValue){
  String value=this.getAttribute(name,Double.toString(defaultValue));
  return Double.parseDouble(value);
}

Fixed version (ground truth):
/** 
 * Returns the value of an attribute.
 * @param name the non-null full name of the attribute.
 * @param defaultValue the default value of the attribute.
 * @return the value, or defaultValue if the attribute does not exist.
 */
public double getDouble(String name,double defaultValue){
  String value=getString(name);
  return (value == null) ? defaultValue : Double.parseDouble(value);
}
Program: 109238
Project: 109238
Buggy source:
/** 
 * Returns a float attribute of the element. If the <b>default</b> parameter is used and the attribute doesn't exist, the <b>default</b> value is returned. When using the version of the method without the <b>default</b> parameter, if the attribute doesn't exist, the value 0 is returned.
 * @param name the name of the attribute
 * @param defaultValue value returned if the attribute is not found
 * @return the value, or defaultValue if the attribute does not exist.
 * @webref
 * @brief Returns a float attribute of the element.
 */
public float getFloat(String name,float defaultValue){
  String value=this.getAttribute(name,Float.toString(defaultValue));
  return Float.parseFloat(value);
}

Fixed version (ground truth):
/** 
 * Returns a float attribute of the element. If the <b>default</b> parameter is used and the attribute doesn't exist, the <b>default</b> value is returned. When using the version of the method without the <b>default</b> parameter, if the attribute doesn't exist, the value 0 is returned.
 * @param name the name of the attribute
 * @param defaultValue value returned if the attribute is not found
 * @return the value, or defaultValue if the attribute does not exist.
 * @webref
 * @brief Returns a float attribute of the element.
 */
public float getFloat(String name,float defaultValue){
  String value=getString(name);
  if (value == null) {
    return defaultValue;
  }
  return PApplet.parseFloat(value,defaultValue);
}
Program: 109239
Project: 109239
Buggy source:
/** 
 * Returns a boolean attribute of the element. If the <b>defaultValue</b> parameter is used and the attribute doesn't exist, the <b>defaultValue</b> is returned. When using the version of the method without the <b>defaultValue</b> parameter, if the attribute doesn't exist, the value false is returned.
 * @param name the name of the attribute
 * @param defaultValue value returned if the attribute is not found
 * @webref
 * @brief Returns a boolean attribute of the element.
 * @return the value, or defaultValue if the attribute does not exist.
 */
public boolean getBoolean(String name,boolean defaultValue){
  String value=this.getAttribute(name,Boolean.toString(defaultValue));
  return value.equals("String_Node_Str") || value.toLowerCase().equals("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Returns a boolean attribute of the element. If the <b>defaultValue</b> parameter is used and the attribute doesn't exist, the <b>defaultValue</b> is returned. When using the version of the method without the <b>defaultValue</b> parameter, if the attribute doesn't exist, the value false is returned.
 * @param name the name of the attribute
 * @param defaultValue value returned if the attribute is not found
 * @webref
 * @brief Returns a boolean attribute of the element.
 * @return the value, or defaultValue if the attribute does not exist.
 */
public boolean getBoolean(String name,boolean defaultValue){
  String value=getString(name);
  return (value != null) && (value.equals("String_Node_Str") || value.toLowerCase().equals("String_Node_Str"));
}
Program: 109240
Project: 109240
Buggy source:
/** 
 * Returns a String attribute of the element. If the <b>default</b> parameter is used and the attribute doesn't exist, the <b>default</b> value is returned. When using the version of the method without the <b>default</b> parameter, if the attribute doesn't exist, the value 0 is returned.
 * @webref
 * @param name the name of the attribute
 * @param default Value value returned if the attribute is not found
 * @brief Returns a String attribute of the element.
 * @deprecated use getString() or getAttribute()
 */
public String getStringAttribute(String name,String defaultValue){
  return getAttribute(name,defaultValue);
}

Fixed version (ground truth):
/** 
 * Returns a String attribute of the element. If the <b>default</b> parameter is used and the attribute doesn't exist, the <b>default</b> value is returned. When using the version of the method without the <b>default</b> parameter, if the attribute doesn't exist, the value 0 is returned.
 * @webref
 * @param name the name of the attribute
 * @param default Value value returned if the attribute is not found
 * @brief Returns a String attribute of the element.
 * @deprecated use getString() or getAttribute()
 */
public String getStringAttribute(String name,String defaultValue){
  return getString(name,defaultValue);
}
Program: 109241
Project: 109241
Buggy source:
public String getString(String name,String defaultValue){
  return getAttribute(name,defaultValue);
}

Fixed version (ground truth):
public String getString(String name,String defaultValue){
  XMLAttribute attr=this.findAttribute(name);
  if (attr == null) {
    return defaultValue;
  }
 else {
    return attr.getValue();
  }
}
Program: 109242
Project: 109242
Buggy source:
/** 
 * Returns an integer attribute of the element. If the <b>default</b> parameter is used and the attribute doesn't exist, the <b>default</b> value is returned. When using the version of the method without the <b>default</b> parameter, if the attribute doesn't exist, the value 0 is returned.
 * @param name the name of the attribute
 * @param defaultValue value returned if the attribute is not found
 * @webref
 * @brief Returns an integer attribute of the element.
 * @return the value, or defaultValue if the attribute does not exist.
 */
public int getInt(String name,int defaultValue){
  String value=this.getAttribute(name,Integer.toString(defaultValue));
  return Integer.parseInt(value);
}

Fixed version (ground truth):
/** 
 * Returns an integer attribute of the element. If the <b>default</b> parameter is used and the attribute doesn't exist, the <b>default</b> value is returned. When using the version of the method without the <b>default</b> parameter, if the attribute doesn't exist, the value 0 is returned.
 * @param name the name of the attribute
 * @param defaultValue value returned if the attribute is not found
 * @webref
 * @brief Returns an integer attribute of the element.
 * @return the value, or defaultValue if the attribute does not exist.
 */
public int getInt(String name,int defaultValue){
  String value=getString(name);
  return (value == null) ? defaultValue : PApplet.parseInt(value,defaultValue);
}
Program: 109243
Project: 109243
Buggy source:
/** 
 * Returns true if the element equals another element.
 * @param rawElement the element to compare to
 */
public boolean equals(Object object){
  if (!(object instanceof XMLElement)) {
    return false;
  }
  XMLElement rawElement=(XMLElement)object;
  if (!this.name.equals(rawElement.getLocalName())) {
    return false;
  }
  if (this.attributes.size() != rawElement.getAttributeCount()) {
    return false;
  }
  Enumeration<XMLAttribute> en=this.attributes.elements();
  while (en.hasMoreElements()) {
    XMLAttribute attr=(XMLAttribute)en.nextElement();
    if (!rawElement.hasAttribute(attr.getName())) {
      return false;
    }
    String value=rawElement.getAttribute(attr.getName(),null);
    if (!attr.getValue().equals(value)) {
      return false;
    }
  }
  if (this.children.size() != rawElement.getChildCount()) {
    return false;
  }
  for (int i=0; i < this.children.size(); i++) {
    XMLElement child1=this.getChild(i);
    XMLElement child2=rawElement.getChild(i);
    if (!child1.equals(child2)) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Returns true if the element equals another element.
 * @param rawElement the element to compare to
 */
public boolean equals(Object object){
  if (!(object instanceof XMLElement)) {
    return false;
  }
  XMLElement rawElement=(XMLElement)object;
  if (!this.name.equals(rawElement.getLocalName())) {
    return false;
  }
  if (this.attributes.size() != rawElement.getAttributeCount()) {
    return false;
  }
  Enumeration<XMLAttribute> en=this.attributes.elements();
  while (en.hasMoreElements()) {
    XMLAttribute attr=(XMLAttribute)en.nextElement();
    if (!rawElement.hasAttribute(attr.getName())) {
      return false;
    }
    String value=rawElement.getString(attr.getName(),null);
    if (!attr.getValue().equals(value)) {
      return false;
    }
  }
  if (this.children.size() != rawElement.getChildCount()) {
    return false;
  }
  for (int i=0; i < this.children.size(); i++) {
    XMLElement child1=this.getChild(i);
    XMLElement child2=rawElement.getChild(i);
    if (!child1.equals(child2)) {
      return false;
    }
  }
  return true;
}
Program: 109245
Project: 109245
Buggy source:
public void directionalLight(float r,float g,float b,float nx,float ny,float nz){
  if (!lights) {
    glEnableLights();
  }
  if (lightCount == MAX_LIGHTS) {
    throw new RuntimeException("String_Node_Str" + MAX_LIGHTS + "String_Node_Str");
  }
  colorCalc(r,g,b);
  lightDiffuse[lightCount][0]=calcR;
  lightDiffuse[lightCount][1]=calcG;
  lightDiffuse[lightCount][2]=calcB;
  lightDiffuse[lightCount][3]=1.0f;
  lightType[lightCount]=DIRECTIONAL;
  lightFalloffConstant[lightCount]=currentLightFalloffConstant;
  lightFalloffLinear[lightCount]=currentLightFalloffLinear;
  lightFalloffQuadratic[lightCount]=currentLightFalloffQuadratic;
  lightSpecular[lightCount][0]=currentLightSpecular[0];
  lightSpecular[lightCount][1]=currentLightSpecular[1];
  lightSpecular[lightCount][2]=currentLightSpecular[2];
  lightSpecular[lightCount][2]=currentLightSpecular[3];
  float invn=1.0f / PApplet.dist(0,0,0,nx,ny,nz);
  lightNormal[lightCount][0]=invn * nx;
  lightNormal[lightCount][1]=invn * ny;
  lightNormal[lightCount][2]=invn * nz;
  lightNormal[lightCount][3]=0.0f;
  glLightEnable(lightCount);
  glLightNoAmbient(lightCount);
  glLightDirection(lightCount);
  glLightDiffuse(lightCount);
  glLightSpecular(lightCount);
  glLightFalloff(lightCount);
  glLightNoSpot(lightCount);
  lightCount++;
}

Fixed version (ground truth):
public void directionalLight(float r,float g,float b,float nx,float ny,float nz){
  if (!lights) {
    glEnableLights();
  }
  if (lightCount == MAX_LIGHTS) {
    throw new RuntimeException("String_Node_Str" + MAX_LIGHTS + "String_Node_Str");
  }
  colorCalc(r,g,b);
  lightDiffuse[lightCount][0]=calcR;
  lightDiffuse[lightCount][1]=calcG;
  lightDiffuse[lightCount][2]=calcB;
  lightDiffuse[lightCount][3]=1.0f;
  lightType[lightCount]=DIRECTIONAL;
  lightFalloffConstant[lightCount]=currentLightFalloffConstant;
  lightFalloffLinear[lightCount]=currentLightFalloffLinear;
  lightFalloffQuadratic[lightCount]=currentLightFalloffQuadratic;
  lightSpecular[lightCount][0]=currentLightSpecular[0];
  lightSpecular[lightCount][1]=currentLightSpecular[1];
  lightSpecular[lightCount][2]=currentLightSpecular[2];
  lightSpecular[lightCount][3]=currentLightSpecular[3];
  float invn=1.0f / PApplet.dist(0,0,0,nx,ny,nz);
  lightNormal[lightCount][0]=invn * nx;
  lightNormal[lightCount][1]=invn * ny;
  lightNormal[lightCount][2]=invn * nz;
  lightNormal[lightCount][3]=0.0f;
  glLightEnable(lightCount);
  glLightNoAmbient(lightCount);
  glLightDirection(lightCount);
  glLightDiffuse(lightCount);
  glLightSpecular(lightCount);
  glLightFalloff(lightCount);
  glLightNoSpot(lightCount);
  lightCount++;
}
Program: 109246
Project: 109246
Buggy source:
public void loadTexture(PTexture.Parameters params){
  if (texture == null) {
    texture=new PTexture(parent,width,height,params);
    texUpdated=false;
  }
  if (pixels != null) {
    pixelsToTexture();
  }
}

Fixed version (ground truth):
public void loadTexture(PTexture.Parameters params){
  if (texture == null) {
    texture=new PTexture(parent,width,height,params);
    texUpdated=false;
  }
  if (pixels == null) {
    loadPixels();
  }
 else {
    pixelsToTexture();
  }
}
Program: 109247
Project: 109247
Buggy source:
/** 
 * Call this when you want to mess with the pixels[] array. <p/> For subclasses where the pixels[] buffer isn't set by default, this should copy all data into the pixels[] array
 */
public void loadPixels(){
  if (pixels == null || pixels.length != width * height) {
    pixels=new int[width * height];
  }
  if (bitmap != null) {
    bitmap.getPixels(pixels,0,width,0,0,width,height);
  }
  if (parent.g.is3D()) {
    loadTexture();
  }
}

Fixed version (ground truth):
/** 
 * Call this when you want to mess with the pixels[] array. <p/> For subclasses where the pixels[] buffer isn't set by default, this should copy all data into the pixels[] array
 */
public void loadPixels(){
  if (pixels == null || pixels.length != width * height) {
    pixels=new int[width * height];
  }
  if (bitmap != null) {
    bitmap.getPixels(pixels,0,width,0,0,width,height);
  }
  if (parent.g.is3D()) {
    if (texture == null) {
      texture=new PTexture(parent,width,height,new PTexture.Parameters(format));
      texUpdated=false;
    }
    pixelsToTexture();
  }
}
Program: 109249
Project: 109249
Buggy source:
/** 
 * Calculate the angle between two vectors, using the dot product
 * @param v1 a vector
 * @param v2 another vector
 * @return the angle between the vectors
 */
static public float angleBetween(PVector v1,PVector v2){
  double dot=v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
  double v1mag=Math.sqrt(v1.x * v1.x + v1.y * v1.y + v1.z * v1.z);
  double v2mag=Math.sqrt(v2.x * v2.x + v2.y * v2.y + v2.z * v2.z);
  double amt=dot / (v1mag * v2mag);
  if (amt <= -1 || amt >= 1) {
    return PConstants.PI;
  }
  return (float)Math.acos(amt);
}

Fixed version (ground truth):
/** 
 * Calculate the angle between two vectors, using the dot product
 * @param v1 a vector
 * @param v2 another vector
 * @return the angle between the vectors
 */
static public float angleBetween(PVector v1,PVector v2){
  double dot=v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
  double v1mag=Math.sqrt(v1.x * v1.x + v1.y * v1.y + v1.z * v1.z);
  double v2mag=Math.sqrt(v2.x * v2.x + v2.y * v2.y + v2.z * v2.z);
  double amt=dot / (v1mag * v2mag);
  if (amt <= -1) {
    return PConstants.PI;
  }
 else   if (amt >= 1) {
    return 0;
  }
  return (float)Math.acos(amt);
}
Program: 109250
Project: 109250
Buggy source:
/** 
 * Returns the full name (i.e. the name including an eventual namespace prefix) of the element.
 * @webref
 * @brief  	Returns the name of the element.
 * @return the name, or null if the element only contains #PCDATA.
 */
public String getName(){
  return this.fullName;
}

Fixed version (ground truth):
/** 
 * Returns the full name (i.e. the name including an eventual namespace prefix) of the element.
 * @webref
 * @brief     Returns the name of the element.
 * @return the name, or null if the element only contains #PCDATA.
 */
public String getName(){
  return this.fullName;
}
Program: 109251
Project: 109251
Buggy source:
/** 
 * Returns the content of an element. If there is no such content, <b>null</b> is returned. =advanced Return the #PCDATA content of the element. If the element has a combination of #PCDATA content and child elements, the #PCDATA sections can be retrieved as unnamed child objects. In this case, this method returns null.
 * @webref 
 * @brief  	Returns the content of an element
 * @return the content.
 */
public String getContent(){
  return this.content;
}

Fixed version (ground truth):
/** 
 * Returns the content of an element. If there is no such content, <b>null</b> is returned. =advanced Return the #PCDATA content of the element. If the element has a combination of #PCDATA content and child elements, the #PCDATA sections can be retrieved as unnamed child objects. In this case, this method returns null.
 * @webref
 * @brief     Returns the content of an element
 * @return the content.
 */
public String getContent(){
  return this.content;
}