nus-yam/ex-repair huggingface dataset:
Program: 163706
Project: 163706
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: 163707
Project: 163707
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: 163710
Project: 163710
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: 163711
Project: 163711
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: 163712
Project: 163712
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: 163713
Project: 163713
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;
}
Program: 163714
Project: 163714
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=getString(name);
  return (value != null) && (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);
  if (value == null) {
    return defaultValue;
  }
  return (value.equals("String_Node_Str") || value.toLowerCase().equals("String_Node_Str"));
}
Program: 163715
Project: 163715
Buggy source:
/** 
 * Returns the name of the element without its namespace. 
 * @return the name, or null if the element only contains #PCDATA.
 */
public String getLocalName(){
  return this.name;
}

Fixed version (ground truth):
/** 
 * Returns the name of the element without its namespace.
 * @return the name, or null if the element only contains #PCDATA.
 */
public String getLocalName(){
  return this.name;
}
Program: 163716
Project: 163716
Buggy source:
/** 
 * Put the names of all children into an array. Same as looping through  each child and calling getName() on each XMLElement.
 */
public String[] listChildren(){
  int childCount=getChildCount();
  String[] outgoing=new String[childCount];
  for (int i=0; i < childCount; i++) {
    outgoing[i]=getChild(i).getName();
  }
  return outgoing;
}

Fixed version (ground truth):
/** 
 * Put the names of all children into an array. Same as looping through each child and calling getName() on each XMLElement.
 */
public String[] listChildren(){
  int childCount=getChildCount();
  String[] outgoing=new String[childCount];
  for (int i=0; i < childCount; i++) {
    outgoing[i]=getChild(i).getName();
  }
  return outgoing;
}
Program: 163717
Project: 163717
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: 163719
Project: 163719
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: 163720
Project: 163720
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: 163721
Project: 163721
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: 163722
Project: 163722
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: 163723
Project: 163723
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: 163724
Project: 163724
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: 163725
Project: 163725
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: 163726
Project: 163726
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: 163727
Project: 163727
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: 163728
Project: 163728
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: 163729
Project: 163729
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: 163730
Project: 163730
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: 163732
Project: 163732
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: 163733
Project: 163733
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: 163735
Project: 163735
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: 163738
Project: 163738
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: 163739
Project: 163739
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: 163740
Project: 163740
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: 163741
Project: 163741
Buggy source:
protected void vertexCheck(){
  if (vertexCount == vertices.length) {
    float temp[][]=new float[vertexCount << 1][VERTEX_FIELD_COUNT];
    System.arraycopy(vertices,0,temp,0,vertexCount);
    vertices=temp;
  }
}

Fixed version (ground truth):
protected void vertexCheck(){
  if (vertexCount == vertices.length) {
    float temp[][]=new float[vertexCount << 1][VERTEX_FIELD_COUNT];
    System.arraycopy(vertices,0,temp,0,vertexCount);
    vertices=temp;
    PImage texTmp[]=new PImage[vertexCount << 1];
    System.arraycopy(verticesTexture,0,texTmp,0,vertexCount);
    verticesTexture=texTmp;
  }
}
Program: 163742
Project: 163742
Buggy source:
protected void addNewFace(boolean firstFace){
  if (faceCount == faceOffset.length) {
    faceOffset=PApplet.expand(faceOffset);
    faceLength=PApplet.expand(faceLength);
    faceTexture=PApplet.expand(faceTexture);
  }
  faceOffset[faceCount]=firstFace ? 0 : triangleCount;
  faceLength[faceCount]=1;
  faceTexture[faceCount]=textureImage;
  faceCount++;
}

Fixed version (ground truth):
protected void addNewFace(boolean firstFace,PImage tex){
  if (faceCount == faceOffset.length) {
    faceOffset=PApplet.expand(faceOffset);
    faceLength=PApplet.expand(faceLength);
    faceTexture=PApplet.expand(faceTexture);
  }
  faceOffset[faceCount]=firstFace ? 0 : triangleCount;
  faceLength[faceCount]=1;
  faceTexture[faceCount]=tex;
  faceCount++;
}
Program: 163744
Project: 163744
Buggy source:
/** 
 * Add the triangle.
 */
protected void addTriangle(int a,int b,int c){
  if (triangleCount == triangles.length) {
    int temp[][]=new int[triangleCount << 1][TRIANGLE_FIELD_COUNT];
    System.arraycopy(triangles,0,temp,0,triangleCount);
    triangles=temp;
  }
  triangles[triangleCount][VERTEX1]=a;
  triangles[triangleCount][VERTEX2]=b;
  triangles[triangleCount][VERTEX3]=c;
  triangleCount++;
  boolean firstFace=triangleCount == 1;
  if (textureImage != textureImagePrev || firstFace) {
    addNewFace(firstFace);
  }
 else {
    faceLength[faceCount - 1]++;
  }
  textureImagePrev=textureImage;
}

Fixed version (ground truth):
/** 
 * Add the triangle.
 */
protected void addTriangle(int a,int b,int c){
  if (triangleCount == triangles.length) {
    int temp[][]=new int[triangleCount << 1][TRIANGLE_FIELD_COUNT];
    System.arraycopy(triangles,0,temp,0,triangleCount);
    triangles=temp;
  }
  triangles[triangleCount][VERTEX1]=a;
  triangles[triangleCount][VERTEX2]=b;
  triangles[triangleCount][VERTEX3]=c;
  PImage tex=verticesTexture[a];
  boolean firstFace=triangleCount == 0;
  if (tex != textureImagePrev || firstFace) {
    addNewFace(firstFace,tex);
  }
 else {
    faceLength[faceCount - 1]++;
  }
  triangleCount++;
  textureImagePrev=tex;
}
Program: 163745
Project: 163745
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: 163746
Project: 163746
Buggy source:
public int addTexture(GL10 gl){
  int[] textures=new int[1];
  gl.glGenTextures(1,textures,0);
  gl.glBindTexture(GL10.GL_TEXTURE_2D,textures[0]);
  gl.glTexParameterf(GL10.GL_TEXTURE_2D,GL10.GL_TEXTURE_MIN_FILTER,GL10.GL_NEAREST);
  gl.glTexParameterf(GL10.GL_TEXTURE_2D,GL10.GL_TEXTURE_MAG_FILTER,GL10.GL_NEAREST);
  gl.glTexParameterf(GL10.GL_TEXTURE_2D,GL10.GL_TEXTURE_WRAP_S,GL10.GL_CLAMP_TO_EDGE);
  gl.glTexParameterf(GL10.GL_TEXTURE_2D,GL10.GL_TEXTURE_WRAP_T,GL10.GL_CLAMP_TO_EDGE);
  gl.glTexImage2D(GL10.GL_TEXTURE_2D,0,GL10.GL_RGBA,texWidth,texHeight,0,GL10.GL_RGBA,GL10.GL_UNSIGNED_BYTE,null);
  gl.glBindTexture(GL10.GL_TEXTURE_2D,0);
  currentTexID=-1;
  if (texIDList == null) {
    texIDList=new int[1];
    texIDList[0]=textures[0];
  }
 else {
    int[] tmp=texIDList;
    texIDList=new int[texIDList.length + 1];
    PApplet.arrayCopy(tmp,texIDList,tmp.length);
    texIDList[tmp.length]=textures[0];
  }
  return textures[0];
}

Fixed version (ground truth):
public int addTexture(GL10 gl){
  int[] textures=new int[1];
  gl.glGenTextures(1,textures,0);
  gl.glBindTexture(GL10.GL_TEXTURE_2D,textures[0]);
  gl.glTexParameterf(GL10.GL_TEXTURE_2D,GL10.GL_TEXTURE_MIN_FILTER,GL10.GL_NEAREST);
  gl.glTexParameterf(GL10.GL_TEXTURE_2D,GL10.GL_TEXTURE_MAG_FILTER,GL10.GL_NEAREST);
  gl.glTexParameterf(GL10.GL_TEXTURE_2D,GL10.GL_TEXTURE_WRAP_S,GL10.GL_CLAMP_TO_EDGE);
  gl.glTexParameterf(GL10.GL_TEXTURE_2D,GL10.GL_TEXTURE_WRAP_T,GL10.GL_CLAMP_TO_EDGE);
  gl.glTexImage2D(GL10.GL_TEXTURE_2D,0,GL10.GL_RGBA,texWidth,texHeight,0,GL10.GL_RGBA,GL10.GL_UNSIGNED_BYTE,null);
  if (texIDList == null) {
    texIDList=new int[1];
    texIDList[0]=textures[0];
  }
 else {
    int[] tmp=texIDList;
    texIDList=new int[texIDList.length + 1];
    PApplet.arrayCopy(tmp,texIDList,tmp.length);
    texIDList[tmp.length]=textures[0];
  }
  currentTexID=textures[0];
  return currentTexID;
}
Program: 163747
Project: 163747
Buggy source:
protected void addToTexture(GL10 gl){
  int[] rgba=new int[width * height];
  int t=0;
  int p=0;
  if (PGraphicsAndroid3D.BIG_ENDIAN) {
    for (int y=0; y < height; y++) {
      for (int x=0; x < width; x++) {
        rgba[t++]=(image.pixels[p++] << 24) | 0xFFFFFFFF;
      }
    }
  }
 else {
    for (int y=0; y < height; y++) {
      for (int x=0; x < width; x++) {
        rgba[t++]=(image.pixels[p++] << 24) | 0xFFFFFFFF;
      }
    }
  }
  if (offsetX + width > texWidth) {
    offsetX=0;
    offsetY+=lineHeight;
    lineHeight=0;
  }
  lineHeight=Math.max(lineHeight,height);
  if (offsetY + lineHeight > texHeight) {
    lastTexID=addTexture(gl);
    offsetX=0;
    offsetY=0;
    lineHeight=0;
  }
  if (lastTexID == -1) {
    lastTexID=texIDList[0];
  }
  if (currentTexID != lastTexID) {
    gl.glBindTexture(GL10.GL_TEXTURE_2D,lastTexID);
    currentTexID=lastTexID;
  }
  gl.glTexSubImage2D(GL10.GL_TEXTURE_2D,0,offsetX,offsetY,width,height,GL10.GL_RGBA,GL10.GL_UNSIGNED_BYTE,IntBuffer.wrap(rgba));
  texture=new TextureInfo(currentTexID,offsetX,offsetY + height,width,-height);
  offsetX+=width;
}

Fixed version (ground truth):
protected void addToTexture(GL10 gl){
  int[] rgba=new int[width * height];
  int t=0;
  int p=0;
  if (PGraphicsAndroid3D.BIG_ENDIAN) {
    for (int y=0; y < height; y++) {
      for (int x=0; x < width; x++) {
        rgba[t++]=0xFFFFFF00 | image.pixels[p++];
      }
    }
  }
 else {
    for (int y=0; y < height; y++) {
      for (int x=0; x < width; x++) {
        rgba[t++]=(image.pixels[p++] << 24) | 0x00FFFFFF;
      }
    }
  }
  if (offsetX + width > texWidth) {
    offsetX=0;
    offsetY+=lineHeight;
    lineHeight=0;
  }
  lineHeight=Math.max(lineHeight,height);
  if (offsetY + lineHeight > texHeight) {
    lastTexID=addTexture(gl);
    offsetX=0;
    offsetY=0;
    lineHeight=0;
  }
  if (lastTexID == -1) {
    lastTexID=texIDList[0];
  }
  if (currentTexID != lastTexID) {
    gl.glBindTexture(GL10.GL_TEXTURE_2D,lastTexID);
    currentTexID=lastTexID;
  }
  gl.glTexSubImage2D(GL10.GL_TEXTURE_2D,0,offsetX,offsetY,width,height,GL10.GL_RGBA,GL10.GL_UNSIGNED_BYTE,IntBuffer.wrap(rgba));
  texture=new TextureInfo(currentTexID,offsetX,offsetY + height,width,-height);
  offsetX+=width;
}
Program: 163748
Project: 163748
Buggy source:
/** 
 * Disables lighting.
 */
public void noLights(){
  lights=false;
  gl.glDisable(GL10.GL_LIGHTING);
  lightCount=0;
}

Fixed version (ground truth):
/** 
 * Disables lighting.
 */
public void noLights(){
  disableLights();
  lightCount=0;
}
Program: 163749
Project: 163749
Buggy source:
public void pointLight(float r,float g,float b,float x,float y,float z){
  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]=POINT;
  lightFalloffConstant[lightCount]=currentLightFalloffConstant;
  lightFalloffLinear[lightCount]=currentLightFalloffLinear;
  lightFalloffQuadratic[lightCount]=currentLightFalloffQuadratic;
  lightSpecular[lightCount][0]=currentLightSpecular[0];
  lightSpecular[lightCount][1]=currentLightSpecular[1];
  lightSpecular[lightCount][2]=currentLightSpecular[2];
  lightPosition[lightCount][0]=x;
  lightPosition[lightCount][1]=y;
  lightPosition[lightCount][2]=z;
  lightPosition[lightCount][3]=1.0f;
  glLightEnable(lightCount);
  glLightNoAmbient(lightCount);
  glLightPosition(lightCount);
  glLightDiffuse(lightCount);
  glLightSpecular(lightCount);
  glLightFalloff(lightCount);
  glLightNoSpot(lightCount);
  lightCount++;
}

Fixed version (ground truth):
public void pointLight(float r,float g,float b,float x,float y,float z){
  if (!lights) {
    enableLights();
  }
  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]=POINT;
  lightFalloffConstant[lightCount]=currentLightFalloffConstant;
  lightFalloffLinear[lightCount]=currentLightFalloffLinear;
  lightFalloffQuadratic[lightCount]=currentLightFalloffQuadratic;
  lightSpecular[lightCount][0]=currentLightSpecular[0];
  lightSpecular[lightCount][1]=currentLightSpecular[1];
  lightSpecular[lightCount][2]=currentLightSpecular[2];
  lightPosition[lightCount][0]=x;
  lightPosition[lightCount][1]=y;
  lightPosition[lightCount][2]=z;
  lightPosition[lightCount][3]=1.0f;
  glLightEnable(lightCount);
  glLightNoAmbient(lightCount);
  glLightPosition(lightCount);
  glLightDiffuse(lightCount);
  glLightSpecular(lightCount);
  glLightFalloff(lightCount);
  glLightNoSpot(lightCount);
  lightCount++;
}
Program: 163752
Project: 163752
Buggy source:
public void directionalLight(float r,float g,float b,float nx,float ny,float nz){
  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) {
    enableLights();
  }
  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++;
}