nus-yam/ex-repair huggingface dataset:
Program: 109144
Project: 109144
Buggy source:
private String httpCall(String urlString,String method,String content,String token) throws Exception {
  StringBuilder result=new StringBuilder();
  URL url=new URL(urlString);
  HttpURLConnection conn;
  conn=(HttpURLConnection)url.openConnection();
  conn.setRequestProperty("String_Node_Str","String_Node_Str");
  conn.setRequestProperty("String_Node_Str","String_Node_Str" + token);
  conn.setRequestMethod(method.toUpperCase());
  if (method.equalsIgnoreCase("String_Node_Str")) {
    conn.setRequestProperty("String_Node_Str","String_Node_Str");
  }
  if (!isNullOrEmpty(content)) {
    conn.setDoOutput(true);
  }
  conn.setDoInput(true);
  conn.setUseCaches(false);
  conn.setAllowUserInteraction(false);
  conn.setRequestProperty("String_Node_Str","String_Node_Str");
  conn.setRequestProperty("String_Node_Str",isNullOrEmpty(content) ? "String_Node_Str" : "String_Node_Str" + content.length());
  conn.connect();
  if (!isNullOrEmpty(content)) {
    OutputStream output=conn.getOutputStream();
    output.write(content.getBytes());
    output.flush();
  }
  InputStream is;
  boolean isError=false;
  if (conn.getResponseCode() < 400) {
    is=conn.getInputStream();
  }
 else {
    is=conn.getErrorStream();
    isError=true;
  }
  BufferedReader rd=new BufferedReader(new InputStreamReader(is,"String_Node_Str"));
  String line;
  while ((line=rd.readLine()) != null) {
    result.append(line);
  }
  rd.close();
  if (isError)   throw new RuntimeException(result.toString());
  return result.toString();
}

Fixed version (ground truth):
private String httpCall(String urlString,String method,String content,String token) throws Exception {
  StringBuilder result=new StringBuilder();
  URL url=new URL(urlString);
  HttpURLConnection conn;
  conn=(HttpURLConnection)url.openConnection();
  conn.setRequestProperty("String_Node_Str","String_Node_Str");
  conn.setRequestProperty("String_Node_Str","String_Node_Str" + token);
  conn.setRequestMethod(method.toUpperCase());
  if (method.equalsIgnoreCase("String_Node_Str")) {
    conn.setRequestProperty("String_Node_Str","String_Node_Str");
  }
  if (!isNullOrEmpty(content)) {
    conn.setDoOutput(true);
  }
  conn.setDoInput(true);
  conn.setUseCaches(false);
  conn.setAllowUserInteraction(false);
  conn.setRequestProperty("String_Node_Str","String_Node_Str");
  conn.setRequestProperty("String_Node_Str",isNullOrEmpty(content) ? "String_Node_Str" : "String_Node_Str" + content.length());
  conn.connect();
  if (!isNullOrEmpty(content)) {
    OutputStream output=conn.getOutputStream();
    output.write(content.getBytes(Charset.forName("String_Node_Str")));
    output.flush();
  }
  InputStream is;
  boolean isError=false;
  if (conn.getResponseCode() < 400) {
    is=conn.getInputStream();
  }
 else {
    is=conn.getErrorStream();
    isError=true;
  }
  BufferedReader rd=new BufferedReader(new InputStreamReader(is,"String_Node_Str"));
  String line;
  while ((line=rd.readLine()) != null) {
    result.append(line);
  }
  rd.close();
  if (isError)   throw new RuntimeException(result.toString());
  return result.toString();
}
Program: 109145
Project: 109145
Buggy source:
private boolean init(@Nonnull Map<String,String> settings){
  String projectId=StringUtils2.trimToEmpty(settings.get("String_Node_Str"));
  if (StringUtils2.isNullOrEmpty(projectId)) {
    logger.info("String_Node_Str");
    projectId=getGkeProjectId();
  }
  if (StringUtils2.isNullOrEmpty(projectId)) {
    logger.log(Level.WARNING,"String_Node_Str");
    return false;
  }
  logger.info("String_Node_Str" + projectId);
  String applicationCredentials=StringUtils2.trimToEmpty(settings.get("String_Node_Str"));
  String serviceAccount=StringUtils2.trimToEmpty(settings.get("String_Node_Str"));
  String serviceAccountKey=StringUtils2.trimToEmpty(settings.get("String_Node_Str"));
  String separator=StringUtils2.trimToEmpty(settings.get("String_Node_Str"));
  this.separator=StringUtils2.isNullOrEmpty(separator) ? "String_Node_Str" : separator;
  String namePrefix=StringUtils2.trimToEmpty(settings.get("String_Node_Str"));
  this.namePrefix=StringUtils2.isNullOrEmpty(namePrefix) ? "String_Node_Str" : namePrefix;
  initStaticLabels(settings);
  return ApiFacade.initConnection(projectId,serviceAccount,serviceAccountKey,applicationCredentials);
}

Fixed version (ground truth):
private boolean init(@Nonnull Map<String,String> settings){
  rfc3339.setTimeZone(TimeZone.getTimeZone("String_Node_Str"));
  String projectId=StringUtils2.trimToEmpty(settings.get("String_Node_Str"));
  if (StringUtils2.isNullOrEmpty(projectId)) {
    logger.info("String_Node_Str");
    projectId=getGoogleProjectId();
  }
  if (StringUtils2.isNullOrEmpty(projectId)) {
    logger.log(Level.WARNING,"String_Node_Str");
    return false;
  }
  logger.info("String_Node_Str" + projectId);
  String applicationCredentials=StringUtils2.trimToEmpty(settings.get("String_Node_Str"));
  String serviceAccount=StringUtils2.trimToEmpty(settings.get("String_Node_Str"));
  String serviceAccountKey=StringUtils2.trimToEmpty(settings.get("String_Node_Str"));
  String separator=StringUtils2.trimToEmpty(settings.get("String_Node_Str"));
  this.separator=StringUtils2.isNullOrEmpty(separator) ? "String_Node_Str" : separator;
  String namePrefix=StringUtils2.trimToEmpty(settings.get("String_Node_Str"));
  this.namePrefix=StringUtils2.isNullOrEmpty(namePrefix) ? "String_Node_Str" : namePrefix;
  initStaticLabels(settings);
  return ApiFacade.initConnection(projectId,serviceAccount,serviceAccountKey,applicationCredentials);
}
Program: 109146
Project: 109146
Buggy source:
private void initStaticLabels(Map<String,String> settings){
  String hostname=StringUtils2.trimToEmpty(settings.get("String_Node_Str"));
  if (StringUtils2.isNullOrEmpty(hostname)) {
    hostname=System.getenv("String_Node_Str");
  }
  logger.info("String_Node_Str" + hostname);
  this.staticLabels.put("String_Node_Str",hostname);
  for (  String key : settings.keySet()) {
    String value=StringUtils2.trimToEmpty(settings.get(key));
    if (StringUtils2.isNullOrEmpty(value) || RESERVED_KEYWORDS.contains(key.toLowerCase().trim())) {
      continue;
    }
    this.staticLabels.put(key,value);
    logger.log(Level.INFO,"String_Node_Str" + key + "String_Node_Str"+ value);
  }
}

Fixed version (ground truth):
private void initStaticLabels(Map<String,String> settings){
  String hostname=StringUtils2.trimToEmpty(settings.get("String_Node_Str"));
  if (StringUtils2.isNullOrEmpty(hostname)) {
    hostname=System.getenv("String_Node_Str");
  }
  logger.info("String_Node_Str" + hostname);
  this.staticLabels.put("String_Node_Str",hostname);
  for (  Map.Entry<String,String> entry : settings.entrySet()) {
    String value=StringUtils2.trimToEmpty(settings.get(entry.getKey()));
    if (StringUtils2.isNullOrEmpty(value) || RESERVED_KEYWORDS.contains(entry.getKey().toLowerCase().trim())) {
      continue;
    }
    this.staticLabels.put(entry.getKey(),value);
    logger.log(Level.INFO,"String_Node_Str" + entry.getKey() + "String_Node_Str"+ value);
  }
}
Program: 109147
Project: 109147
Buggy source:
private static String getNow(){
  return rfc3339.format(new Date());
}

Fixed version (ground truth):
private String getNow(){
  return rfc3339.format(new Date());
}
Program: 109148
Project: 109148
Buggy source:
private synchronized void readObject(ObjectInputStream inputStream) throws IOException, ClassNotFoundException {
  inputStream.defaultReadObject();
  table=new HashIndexTable();
  updateHashIndex();
}

Fixed version (ground truth):
private void readObject(ObjectInputStream inputStream) throws IOException, ClassNotFoundException {
  inputStream.defaultReadObject();
  table=new HashIndexTable();
  updateHashIndex();
}
Program: 109149
Project: 109149
Buggy source:
@Nonnull public static Document getFileAsDocument(@Nonnull Resource resource) throws IoRuntimeException {
  if (resource == null)   throw new IoRuntimeException(new NullPointerException("String_Node_Str"));
  DocumentBuilder dBuilder;
  try {
    dBuilder=DocumentBuilderFactory.newInstance().newDocumentBuilder();
    try {
      File configurationFile=resource.getFile();
      return dBuilder.parse(configurationFile);
    }
 catch (    FileNotFoundException e) {
      return dBuilder.parse(resource.getInputStream());
    }
  }
 catch (  ParserConfigurationException|SAXException e) {
    throw new IoRuntimeException(e);
  }
catch (  IOException e) {
    throw IoRuntimeException.propagate(e);
  }
}

Fixed version (ground truth):
@Nonnull public static Document getFileAsDocument(@Nonnull Resource resource) throws IoRuntimeException {
  if (resource == null)   throw new IoRuntimeException(new NullPointerException("String_Node_Str"));
  DocumentBuilder dBuilder;
  try {
    dBuilder=DocumentBuilderFactory.newInstance().newDocumentBuilder();
    try {
      File configurationFile=resource.getFile();
      return dBuilder.parse(configurationFile);
    }
 catch (    FileNotFoundRuntimeException e) {
      return dBuilder.parse(resource.getInputStream());
    }
  }
 catch (  ParserConfigurationException|SAXException e) {
    throw new IoRuntimeException(e);
  }
catch (  IOException e) {
    throw IoRuntimeException.propagate(e);
  }
}
Program: 109151
Project: 109151
Buggy source:
@Nonnull public String getResultName(@Nonnull Query query,@Nonnull ObjectName objectName,@Nullable String key){
  StringBuilder result=_getResultName(query,objectName);
  if (key != null) {
    result.append("String_Node_Str");
    result.append(key);
  }
  return result.toString();
}

Fixed version (ground truth):
@Nonnull public String getResultName(@Nonnull Query query,@Nonnull ObjectName objectName,@Nullable String key){
  String result;
  if (query.getResultAlias() == null) {
    if (key == null) {
      result=escapeObjectName(objectName) + "String_Node_Str" + query.getAttribute();
    }
 else {
      result=escapeObjectName(objectName) + "String_Node_Str" + query.getAttribute()+ "String_Node_Str"+ key;
    }
  }
 else {
    result=resolveExpression(query.getResultAlias(),objectName);
  }
  return result;
}
Program: 109152
Project: 109152
Buggy source:
@EventHandler public void init(FMLInitializationEvent event){
  ModRecipes.InitializeRecipes();
  ResearchCategories.registerCategory("String_Node_Str",(String)null,new AspectList(),new ResourceLocation("String_Node_Str","String_Node_Str"),new ResourceLocation("String_Node_Str","String_Node_Str"),new ResourceLocation("String_Node_Str","String_Node_Str"));
  ThaumcraftApi.registerResearchLocation(new ResourceLocation("String_Node_Str","String_Node_Str"));
  ThaumcraftApi.registerResearchLocation(new ResourceLocation("String_Node_Str","String_Node_Str"));
  ThaumcraftApi.registerResearchLocation(new ResourceLocation("String_Node_Str","String_Node_Str"));
  proxy.registerRenderers();
  FocusEngine.registerElement(FocusEffectDislocate.class,new ResourceLocation("String_Node_Str","String_Node_Str"),8760709);
}

Fixed version (ground truth):
@EventHandler public void init(FMLInitializationEvent event){
  proxy.init(event);
  ModRecipes.InitializeRecipes();
  ResearchCategories.registerCategory("String_Node_Str",(String)null,new AspectList(),new ResourceLocation("String_Node_Str","String_Node_Str"),new ResourceLocation("String_Node_Str","String_Node_Str"),new ResourceLocation("String_Node_Str","String_Node_Str"));
  ThaumcraftApi.registerResearchLocation(new ResourceLocation("String_Node_Str","String_Node_Str"));
  ThaumcraftApi.registerResearchLocation(new ResourceLocation("String_Node_Str","String_Node_Str"));
  ThaumcraftApi.registerResearchLocation(new ResourceLocation("String_Node_Str","String_Node_Str"));
  proxy.registerRenderers();
  FocusEngine.registerElement(FocusEffectDislocate.class,new ResourceLocation("String_Node_Str","String_Node_Str"),8760709);
}
Program: 109153
Project: 109153
Buggy source:
@EventHandler public void preInit(FMLPreInitializationEvent event){
  logger=event.getModLog();
}

Fixed version (ground truth):
@EventHandler public void preInit(FMLPreInitializationEvent event){
  logger=event.getModLog();
  PacketHandler.registerMessages(LibMisc.MOD_ID);
}
Program: 109154
Project: 109154
Buggy source:
private SavedState(Parcel in){
  super(in);
  state=in.readParcelable(null);
}

Fixed version (ground truth):
private SavedState(Parcel in){
  super(in);
  state=(MultiStateViewData)in.readParcelable(MultiStateViewData.class.getClassLoader());
}
Program: 109155
Project: 109155
Buggy source:
private static void open(){
  props=new Properties();
  try {
    props.load(new FileReader(PROP_FILE));
  }
 catch (  FileNotFoundException e) {
    throw new RuntimeException(e);
  }
catch (  IOException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
private static void open(){
  props=new Properties();
  try {
    props.load(new FileReader(PROP_FILE));
    File downloadFile=new File((String)props.get(DIRECTORY_PROP));
    if (!downloadFile.exists()) {
      downloadFile.mkdirs();
    }
  }
 catch (  FileNotFoundException e) {
    throw new RuntimeException(e);
  }
catch (  IOException e) {
    throw new RuntimeException(e);
  }
}
Program: 109157
Project: 109157
Buggy source:
protected static IntBuffer updateIntBuffer(IntBuffer buf,int[] arr,boolean wrap){
  if (USE_DIRECT_BUFFERS) {
    if (buf == null || buf.capacity() < arr.length) {
      buf=PGL.allocateDirectIntBuffer(arr.length);
    }
    buf.position(0);
    buf.put(arr);
    buf.rewind();
  }
 else {
    if (wrap) {
      buf=IntBuffer.wrap(arr);
    }
 else {
      if (buf == null || buf.capacity() < arr.length) {
        buf=IntBuffer.allocate(arr.length);
      }
      buf.position(0);
      buf.put(arr);
      buf.rewind();
    }
  }
  return buf;
}

Fixed version (ground truth):
protected static void updateIntBuffer(IntBuffer buf,int[] arr,int offset,int size){
  if (USE_DIRECT_BUFFERS || (buf.hasArray() && buf.array() != arr)) {
    buf.position(offset);
    buf.put(arr,offset,size);
    buf.rewind();
  }
}
Program: 109158
Project: 109158
Buggy source:
protected static FloatBuffer updateFloatBuffer(FloatBuffer buf,float[] arr,boolean wrap){
  if (USE_DIRECT_BUFFERS) {
    if (buf == null || buf.capacity() < arr.length) {
      buf=PGL.allocateDirectFloatBuffer(arr.length);
    }
    buf.position(0);
    buf.put(arr);
    buf.rewind();
  }
 else {
    if (wrap) {
      buf=FloatBuffer.wrap(arr);
    }
 else {
      if (buf == null || buf.capacity() < arr.length) {
        buf=FloatBuffer.allocate(arr.length);
      }
      buf.position(0);
      buf.put(arr);
      buf.rewind();
    }
  }
  return buf;
}

Fixed version (ground truth):
protected static void updateFloatBuffer(FloatBuffer buf,float[] arr,int offset,int size){
  if (USE_DIRECT_BUFFERS || (buf.hasArray() && buf.array() != arr)) {
    buf.position(offset);
    buf.put(arr,offset,size);
    buf.rewind();
  }
}
Program: 109159
Project: 109159
Buggy source:
protected static ByteBuffer updateByteBuffer(ByteBuffer buf,byte[] arr,boolean wrap){
  if (USE_DIRECT_BUFFERS) {
    if (buf == null || buf.capacity() < arr.length) {
      buf=PGL.allocateDirectByteBuffer(arr.length);
    }
    buf.position(0);
    buf.put(arr);
    buf.rewind();
  }
 else {
    if (wrap) {
      buf=ByteBuffer.wrap(arr);
    }
 else {
      if (buf == null || buf.capacity() < arr.length) {
        buf=ByteBuffer.allocate(arr.length);
      }
      buf.position(0);
      buf.put(arr);
      buf.rewind();
    }
  }
  return buf;
}

Fixed version (ground truth):
protected static void updateByteBuffer(ByteBuffer buf,byte[] arr,int offset,int size){
  if (USE_DIRECT_BUFFERS || (buf.hasArray() && buf.array() != arr)) {
    buf.position(offset);
    buf.put(arr,offset,size);
    buf.rewind();
  }
}
Program: 109160
Project: 109160
Buggy source:
protected static ShortBuffer updateShortBuffer(ShortBuffer buf,short[] arr,boolean wrap){
  if (USE_DIRECT_BUFFERS) {
    if (buf == null || buf.capacity() < arr.length) {
      buf=PGL.allocateDirectShortBuffer(arr.length);
    }
    buf.position(0);
    buf.put(arr);
    buf.rewind();
  }
 else {
    if (wrap) {
      buf=ShortBuffer.wrap(arr);
    }
 else {
      if (buf == null || buf.capacity() < arr.length) {
        buf=ShortBuffer.allocate(arr.length);
      }
      buf.position(0);
      buf.put(arr);
      buf.rewind();
    }
  }
  return buf;
}

Fixed version (ground truth):
protected static void updateShortBuffer(ShortBuffer buf,short[] arr,int offset,int size){
  if (USE_DIRECT_BUFFERS || (buf.hasArray() && buf.array() != arr)) {
    buf.position(offset);
    buf.put(arr,offset,size);
    buf.rewind();
  }
}
Program: 109165
Project: 109165
Buggy source:
protected void restoreGL(){
  blendMode(blendMode);
  if (hints[DISABLE_DEPTH_TEST]) {
    pgl.disable(PGL.DEPTH_TEST);
  }
 else {
    pgl.enable(PGL.DEPTH_TEST);
  }
  pgl.depthFunc(PGL.LEQUAL);
  if (quality < 2) {
    pgl.disable(PGL.MULTISAMPLE);
  }
 else {
    pgl.enable(PGL.MULTISAMPLE);
    pgl.disable(PGL.POINT_SMOOTH);
    pgl.disable(PGL.LINE_SMOOTH);
    pgl.disable(PGL.POLYGON_SMOOTH);
  }
  pgl.viewport(viewport.get(0),viewport.get(1),viewport.get(2),viewport.get(3));
  if (clip) {
    pgl.enable(PGL.SCISSOR_TEST);
    pgl.scissor(clipRect[0],clipRect[1],clipRect[2],clipRect[3]);
  }
 else {
    pgl.disable(PGL.SCISSOR_TEST);
  }
  pgl.frontFace(PGL.CW);
  pgl.disable(PGL.CULL_FACE);
  pgl.activeTexture(PGL.TEXTURE0);
  if (hints[DISABLE_DEPTH_MASK]) {
    pgl.depthMask(false);
  }
 else {
    pgl.depthMask(true);
  }
  currentFramebuffer.bind();
  pgl.drawBuffer(currentFramebuffer.getDefaultDrawBuffer());
}

Fixed version (ground truth):
protected void restoreGL(){
  setBlendMode(blendMode);
  if (hints[DISABLE_DEPTH_TEST]) {
    pgl.disable(PGL.DEPTH_TEST);
  }
 else {
    pgl.enable(PGL.DEPTH_TEST);
  }
  pgl.depthFunc(PGL.LEQUAL);
  if (quality < 2) {
    pgl.disable(PGL.MULTISAMPLE);
  }
 else {
    pgl.enable(PGL.MULTISAMPLE);
    pgl.disable(PGL.POINT_SMOOTH);
    pgl.disable(PGL.LINE_SMOOTH);
    pgl.disable(PGL.POLYGON_SMOOTH);
  }
  pgl.viewport(viewport.get(0),viewport.get(1),viewport.get(2),viewport.get(3));
  if (clip) {
    pgl.enable(PGL.SCISSOR_TEST);
    pgl.scissor(clipRect[0],clipRect[1],clipRect[2],clipRect[3]);
  }
 else {
    pgl.disable(PGL.SCISSOR_TEST);
  }
  pgl.frontFace(PGL.CW);
  pgl.disable(PGL.CULL_FACE);
  pgl.activeTexture(PGL.TEXTURE0);
  if (hints[DISABLE_DEPTH_MASK]) {
    pgl.depthMask(false);
  }
 else {
    pgl.depthMask(true);
  }
  currentFramebuffer.bind();
  pgl.drawBuffer(currentFramebuffer.getDefaultDrawBuffer());
}
Program: 109166
Project: 109166
Buggy source:
protected void drawTexture(int x,int y,int w,int h){
  pgl.drawTexture(texture.glTarget,texture.glName,texture.glWidth,texture.glHeight,x,y,x + w,y + h,x,height - (y + h),x + w,height - y);
}

Fixed version (ground truth):
protected void drawTexture(int x,int y,int w,int h){
  pgl.disable(PGL.BLEND);
  pgl.drawTexture(texture.glTarget,texture.glName,texture.glWidth,texture.glHeight,x,y,x + w,y + h,x,height - (y + h),x + w,height - y);
  pgl.enable(PGL.BLEND);
}
Program: 109168
Project: 109168
Buggy source:
protected void beginDraw(boolean clear0){
  if (!clear0 && glColorFbo[0] != 0) {
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,glColorFbo[0]);
    GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER,GLES20.GL_COLOR_ATTACHMENT0,GLES20.GL_TEXTURE_2D,glColorTex[backTex],0);
    usingFBOlayer=true;
  }
 else {
    usingFBOlayer=false;
  }
}

Fixed version (ground truth):
protected void beginDraw(boolean clear0){
  if ((!clear0 || FORCE_SCREEN_FBO) && glColorFbo[0] != 0) {
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,glColorFbo[0]);
    GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER,GLES20.GL_COLOR_ATTACHMENT0,GLES20.GL_TEXTURE_2D,glColorTex[backTex],0);
    if (firstFrame) {
      GLES20.glClearColor(0,0,0,0);
      GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
    }
 else     if (!clear0) {
      drawTexture(GLES20.GL_TEXTURE_2D,glColorTex[frontTex],fboWidth,fboHeight,0,0,pg.width,pg.height,0,0,pg.width,pg.height);
    }
    usingFBOlayer=true;
  }
 else {
    usingFBOlayer=false;
  }
  if (firstFrame) {
    firstFrame=false;
  }
}
Program: 109169
Project: 109169
Buggy source:
protected void endDraw(boolean clear){
  if (usingFBOlayer) {
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,0);
    GLES20.glClearDepthf(1);
    GLES20.glClearColor(0,0,0,0);
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
    GLES20.glDisable(GLES20.GL_BLEND);
    drawTexture(GLES20.GL_TEXTURE_2D,glColorTex[backTex],fboWidth,fboHeight,0,0,pg.width,pg.height,0,0,pg.width,pg.height);
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,glColorFbo[0]);
    if (!clear) {
      GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER,GLES20.GL_COLOR_ATTACHMENT0,GLES20.GL_TEXTURE_2D,glColorTex[frontTex],0);
      drawTexture(GLES20.GL_TEXTURE_2D,glColorTex[backTex],fboWidth,fboHeight,0,0,pg.width,pg.height,0,0,pg.width,pg.height);
      GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER,GLES20.GL_COLOR_ATTACHMENT0,GLES20.GL_TEXTURE_2D,glColorTex[backTex],0);
    }
    int temp=frontTex;
    frontTex=backTex;
    backTex=temp;
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,0);
  }
}

Fixed version (ground truth):
protected void endDraw(boolean clear){
  if (usingFBOlayer) {
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,0);
    GLES20.glClearDepthf(1);
    GLES20.glClearColor(0,0,0,0);
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
    GLES20.glDisable(GLES20.GL_BLEND);
    drawTexture(GLES20.GL_TEXTURE_2D,glColorTex[backTex],fboWidth,fboHeight,0,0,pg.width,pg.height,0,0,pg.width,pg.height);
    int temp=frontTex;
    frontTex=backTex;
    backTex=temp;
  }
}
Program: 109171
Project: 109171
Buggy source:
private final float cos(float angle){
  return (float)Math.cos(angle);
}

Fixed version (ground truth):
static private final float cos(float angle){
  return (float)Math.cos(angle);
}
Program: 109172
Project: 109172
Buggy source:
private final float sin(float angle){
  return (float)Math.sin(angle);
}

Fixed version (ground truth):
static private final float sin(float angle){
  return (float)Math.sin(angle);
}
Program: 109173
Project: 109173
Buggy source:
private final float max(float a,float b){
  return (a > b) ? a : b;
}

Fixed version (ground truth):
static private final float max(float a,float b){
  return (a > b) ? a : b;
}
Program: 109174
Project: 109174
Buggy source:
private final float abs(float a){
  return (a < 0) ? -a : a;
}

Fixed version (ground truth):
static private final float abs(float a){
  return (a < 0) ? -a : a;
}
Program: 109175
Project: 109175
Buggy source:
protected void handleKeyEvent(KeyEvent event){
switch (event.getAction()) {
case KeyEvent.PRESSED:
    keyPressed=true;
  keyPressed();
break;
case KeyEvent.RELEASED:
keyPressed=false;
keyReleased();
break;
}
if (event.getAction() == KeyEvent.PRESSED && event.getKeyCode() == android.view.KeyEvent.KEYCODE_BACK) {
exit();
}
}

Fixed version (ground truth):
protected void handleKeyEvent(KeyEvent event){
switch (event.getAction()) {
case KeyEvent.PRESSED:
    keyPressed=true;
  keyPressed();
break;
case KeyEvent.RELEASED:
keyPressed=false;
keyReleased();
break;
}
handleMethods("String_Node_Str",new Object[]{event});
if (event.getAction() == KeyEvent.PRESSED && event.getKeyCode() == android.view.KeyEvent.KEYCODE_BACK) {
exit();
}
}
Program: 109176
Project: 109176
Buggy source:
static protected void copyGeometry(PShape src,PShape dest){
  copyMatrix(src,dest);
  copyStyles(src,dest);
  copyImage(src,dest);
  if (src.style) {
    for (int i=0; i < src.vertexCount; i++) {
      float[] vert=src.vertices[i];
      dest.normal(vert[PGraphics.NX],vert[PGraphics.NY],vert[PGraphics.NZ]);
      dest.vertex(vert[X],vert[Y],vert[Z],vert[PGraphics.U],vert[PGraphics.V]);
    }
  }
 else {
    for (int i=0; i < src.vertexCount; i++) {
      float[] vert=src.vertices[i];
      if (vert[Z] == 0) {
        dest.vertex(vert[X],vert[Y]);
      }
 else {
        dest.vertex(vert[X],vert[Y],vert[Z]);
      }
    }
  }
  dest.end();
}

Fixed version (ground truth):
static protected void copyGeometry(PShape src,PShape dest){
  copyMatrix(src,dest);
  copyStyles(src,dest);
  copyImage(src,dest);
  if (src.style) {
    for (int i=0; i < src.vertexCount; i++) {
      float[] vert=src.vertices[i];
      dest.fill(vert[PGraphics.R] * 255,vert[PGraphics.G] * 255,vert[PGraphics.B] * 255,vert[PGraphics.A] * 255);
      if (0 < PApplet.dist(vert[PGraphics.NX],vert[PGraphics.NY],vert[PGraphics.NZ],0,0,0)) {
        dest.normal(vert[PGraphics.NX],vert[PGraphics.NY],vert[PGraphics.NZ]);
      }
      dest.vertex(vert[X],vert[Y],vert[Z],vert[PGraphics.U],vert[PGraphics.V]);
    }
  }
 else {
    for (int i=0; i < src.vertexCount; i++) {
      float[] vert=src.vertices[i];
      if (vert[Z] == 0) {
        dest.vertex(vert[X],vert[Y]);
      }
 else {
        dest.vertex(vert[X],vert[Y],vert[Z]);
      }
    }
  }
  dest.end();
}
Program: 109177
Project: 109177
Buggy source:
protected void addChildren(ArrayList<OBJFace> faces,ArrayList<OBJMaterial> materials,ArrayList<PVector> coords,ArrayList<PVector> normals,ArrayList<PVector> texcoords){
  int mtlIdxCur=-1;
  OBJMaterial mtl=null;
  for (int i=0; i < faces.size(); i++) {
    OBJFace face=faces.get(i);
    if (mtlIdxCur != face.matIdx) {
      mtlIdxCur=PApplet.max(0,face.matIdx);
      mtl=materials.get(mtlIdxCur);
    }
    PShape child=new PShapeOBJ(face,mtl,coords,normals,texcoords);
    addChild(child);
  }
}

Fixed version (ground truth):
protected void addChildren(ArrayList<OBJFace> faces,ArrayList<OBJMaterial> materials,ArrayList<PVector> coords,ArrayList<PVector> normals,ArrayList<PVector> texcoords){
  int mtlIdxCur=-1;
  OBJMaterial mtl=null;
  for (int i=0; i < faces.size(); i++) {
    OBJFace face=faces.get(i);
    if (mtlIdxCur != face.matIdx || face.matIdx == -1) {
      mtlIdxCur=PApplet.max(0,face.matIdx);
      mtl=materials.get(mtlIdxCur);
    }
    PShape child=new PShapeOBJ(face,mtl,coords,normals,texcoords);
    addChild(child);
  }
}
Program: 109180
Project: 109180
Buggy source:
static protected PShape loadShapeImpl(PGraphics pg,String filename,String extension){
  PShapeOBJ obj=null;
  if (extension.equals("String_Node_Str")) {
    obj=new PShapeOBJ(pg.parent,filename);
  }
 else   if (extension.equals("String_Node_Str")) {
    try {
      InputStream input=new GZIPInputStream(pg.parent.createInput(filename));
      obj=new PShapeOBJ(pg.parent,PApplet.createReader(input));
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
  if (obj != null) {
    boolean prevStroke=pg.stroke;
    int prevTextureMode=pg.textureMode;
    pg.stroke=false;
    pg.textureMode=NORMAL;
    PShapeOpenGL p3d=PShapeOpenGL.createShape3D(pg.parent,obj);
    pg.stroke=prevStroke;
    pg.textureMode=prevTextureMode;
    return p3d;
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
static protected PShape loadShapeImpl(PGraphics pg,String filename,String extension){
  PShapeOBJ obj=null;
  if (extension.equals("String_Node_Str")) {
    obj=new PShapeOBJ(pg.parent,filename);
  }
 else   if (extension.equals("String_Node_Str")) {
    try {
      InputStream input=new GZIPInputStream(pg.parent.createInput(filename));
      obj=new PShapeOBJ(pg.parent,PApplet.createReader(input));
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
  if (obj != null) {
    int prevTextureMode=pg.textureMode;
    pg.textureMode=NORMAL;
    PShapeOpenGL p3d=PShapeOpenGL.createShape3D(pg.parent,obj);
    pg.textureMode=prevTextureMode;
    return p3d;
  }
 else {
    return null;
  }
}
Program: 109181
Project: 109181
Buggy source:
protected int getTypeFromVertexShader(String filename){
  String[] source=parent.loadStrings(filename);
  Pattern pointPattern=Pattern.compile("String_Node_Str");
  Pattern linePattern=Pattern.compile("String_Node_Str");
  Pattern lightPattern1=Pattern.compile("String_Node_Str");
  Pattern lightPattern2=Pattern.compile("String_Node_Str");
  Pattern texPattern=Pattern.compile("String_Node_Str");
  int type=PShader.COLOR;
  for (int i=0; i < source.length; i++) {
    boolean foundPoint=pointPattern.matcher(source[i]).find();
    boolean foundLine=linePattern.matcher(source[i]).find();
    boolean foundLight=lightPattern1.matcher(source[i]).find() || lightPattern2.matcher(source[i]).find();
    boolean foundTex=texPattern.matcher(source[i]).find();
    if (foundPoint) {
      type=PShader.POINT;
    }
 else     if (foundLine) {
      type=PShader.LINE;
    }
 else     if (foundLight && foundTex) {
      type=PShader.TEXLIGHT;
    }
 else     if (foundLight) {
      type=PShader.LIGHT;
    }
 else     if (foundTex) {
      type=PShader.TEXTURE;
    }
    if (type != PShader.COLOR)     break;
  }
  return type;
}

Fixed version (ground truth):
protected int getTypeFromVertexShader(String filename){
  String[] source=parent.loadStrings(filename);
  Pattern pointPattern=Pattern.compile("String_Node_Str");
  Pattern linePattern=Pattern.compile("String_Node_Str");
  Pattern lightPattern1=Pattern.compile("String_Node_Str");
  Pattern lightPattern2=Pattern.compile("String_Node_Str");
  Pattern texPattern=Pattern.compile("String_Node_Str");
  boolean foundPoint=false;
  boolean foundLine=false;
  boolean foundLight=false;
  boolean foundTex=false;
  for (int i=0; i < source.length; i++) {
    foundPoint|=pointPattern.matcher(source[i]).find();
    foundLine|=linePattern.matcher(source[i]).find();
    foundLight|=lightPattern1.matcher(source[i]).find();
    foundLight|=lightPattern2.matcher(source[i]).find();
    foundTex|=texPattern.matcher(source[i]).find();
  }
  int type=PShader.COLOR;
  if (foundPoint) {
    type=PShader.POINT;
  }
 else   if (foundLine) {
    type=PShader.LINE;
  }
 else   if (foundLight && foundTex) {
    type=PShader.TEXLIGHT;
  }
 else   if (foundLight) {
    type=PShader.LIGHT;
  }
 else   if (foundTex) {
    type=PShader.TEXTURE;
  }
  return type;
}
Program: 109182
Project: 109182
Buggy source:
public final float hue(int what){
  if (what != cacheHsbKey) {
    Color.RGBToHSV((what >> 16) & 0xff,(what >> 8) & 0xff,what & 0xff,cacheHsbValue);
    cacheHsbKey=what;
  }
  return cacheHsbValue[0] * colorModeX;
}

Fixed version (ground truth):
public final float hue(int what){
  if (what != cacheHsbKey) {
    Color.RGBToHSV((what >> 16) & 0xff,(what >> 8) & 0xff,what & 0xff,cacheHsbValue);
    cacheHsbKey=what;
  }
  return (cacheHsbValue[0] / 360f) * colorModeX;
}
Program: 109183
Project: 109183
Buggy source:
public void setFrameRate(float framerate){
  pgl.setFramerate(framerate);
}

Fixed version (ground truth):
public void setFrameRate(float frameRate){
  pgl.setFrameRate(frameRate);
}
Program: 109184
Project: 109184
Buggy source:
public Object initCache(PImage img){
  Texture tex=(Texture)img.getCache(pgPrimary);
  if (tex == null || tex.contextIsOutdated()) {
    tex=addTexture(img);
    img.loadPixels();
    tex.set(img.pixels);
  }
  return tex;
}

Fixed version (ground truth):
public Object initCache(PImage img){
  Texture tex=(Texture)img.getCache(pgPrimary);
  if (tex == null || tex.contextIsOutdated()) {
    tex=addTexture(img);
    if (tex != null) {
      img.loadPixels();
      tex.set(img.pixels);
    }
  }
  return tex;
}
Program: 109185
Project: 109185
Buggy source:
protected boolean bufferUpdate(int[] pixels){
  BufferData data=null;
  try {
    data=bufferCache.remove(0);
  }
 catch (  NoSuchElementException ex) {
    PGraphics.showWarning("String_Node_Str");
  }
  if (data != null) {
    if ((data.w != width) || (data.h != height)) {
      init(data.w,data.h);
    }
    bind();
    setNative(data.rgbBuf,0,0,width,height);
    unbind();
    data.rgbBuf.get(pixels);
    convertToARGB(pixels);
    data.dispose();
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
protected boolean bufferUpdate(int[] pixels){
  BufferData data=null;
  try {
    data=bufferCache.remove(0);
  }
 catch (  NoSuchElementException ex) {
    PGraphics.showWarning("String_Node_Str");
  }
  if (data != null) {
    if ((data.w != width) || (data.h != height)) {
      init(data.w,data.h);
    }
    setNative(data.rgbBuf,0,0,width,height);
    data.rgbBuf.get(pixels);
    convertToARGB(pixels);
    data.dispose();
    return true;
  }
 else {
    return false;
  }
}
Program: 109186
Project: 109186
Buggy source:
void addArc(float a,float b,float c,float d,float start,float stop,boolean fill,boolean stroke,int ellipseMode){
  float x=a;
  float y=b;
  float w=c;
  float h=d;
  if (ellipseMode == CORNERS) {
    w=c - a;
    h=d - b;
  }
 else   if (ellipseMode == RADIUS) {
    x=a - c;
    y=b - d;
    w=c * 2;
    h=d * 2;
  }
 else   if (ellipseMode == CENTER) {
    x=a - c / 2f;
    y=b - d / 2f;
  }
  if (Float.isInfinite(start) || Float.isInfinite(stop))   return;
  if (stop < start)   return;
  while (start < 0) {
    start+=TWO_PI;
    stop+=TWO_PI;
  }
  if (stop - start > TWO_PI) {
    start=0;
    stop=TWO_PI;
  }
  float hr=w / 2f;
  float vr=h / 2f;
  float centerX=x + hr;
  float centerY=y + vr;
  int startLUT=(int)(0.5f + (start / TWO_PI) * SINCOS_LENGTH);
  int stopLUT=(int)(0.5f + (stop / TWO_PI) * SINCOS_LENGTH);
  if (fill) {
    vertex(centerX,centerY,VERTEX);
  }
  int increment=1;
  int pidx, idx;
  pidx=idx=0;
  for (int i=startLUT; i < stopLUT; i+=increment) {
    int ii=i % SINCOS_LENGTH;
    if (ii < 0)     ii+=SINCOS_LENGTH;
    idx=addVertex(centerX + cosLUT[ii] * hr,centerY + sinLUT[ii] * vr,VERTEX);
    if (0 < i) {
      if (stroke)       addEdge(pidx,idx,i == 1,false);
    }
    pidx=idx;
  }
  idx=addVertex(centerX + cosLUT[stopLUT % SINCOS_LENGTH] * hr,centerY + sinLUT[stopLUT % SINCOS_LENGTH] * vr,VERTEX);
  if (stroke)   addEdge(pidx,idx,false,true);
}

Fixed version (ground truth):
void addArc(float a,float b,float c,float d,float start,float stop,boolean fill,boolean stroke,int ellipseMode){
  float x=a;
  float y=b;
  float w=c;
  float h=d;
  if (ellipseMode == CORNERS) {
    w=c - a;
    h=d - b;
  }
 else   if (ellipseMode == RADIUS) {
    x=a - c;
    y=b - d;
    w=c * 2;
    h=d * 2;
  }
 else   if (ellipseMode == CENTER) {
    x=a - c / 2f;
    y=b - d / 2f;
  }
  if (Float.isInfinite(start) || Float.isInfinite(stop))   return;
  if (stop < start)   return;
  while (start < 0) {
    start+=TWO_PI;
    stop+=TWO_PI;
  }
  if (stop - start > TWO_PI) {
    start=0;
    stop=TWO_PI;
  }
  float hr=w / 2f;
  float vr=h / 2f;
  float centerX=x + hr;
  float centerY=y + vr;
  int startLUT=(int)(0.5f + (start / TWO_PI) * SINCOS_LENGTH);
  int stopLUT=(int)(0.5f + (stop / TWO_PI) * SINCOS_LENGTH);
  if (fill) {
    vertex(centerX,centerY,VERTEX);
  }
  int increment=1;
  int pidx, idx;
  pidx=idx=0;
  for (int i=startLUT; i < stopLUT; i+=increment) {
    int ii=i % SINCOS_LENGTH;
    if (ii < 0)     ii+=SINCOS_LENGTH;
    idx=addVertex(centerX + cosLUT[ii] * hr,centerY + sinLUT[ii] * vr,VERTEX);
    if (startLUT < i) {
      if (stroke)       addEdge(pidx,idx,i == startLUT + 1,false);
    }
    pidx=idx;
  }
  idx=addVertex(centerX + cosLUT[stopLUT % SINCOS_LENGTH] * hr,centerY + sinLUT[stopLUT % SINCOS_LENGTH] * vr,VERTEX);
}
Program: 109187
Project: 109187
Buggy source:
public void hint(int which){
  boolean oldValue=hints[which];
  super.hint(which);
  boolean newValue=hints[which];
  if (oldValue == newValue) {
    return;
  }
  if (which == DISABLE_DEPTH_TEST) {
    flush();
    pgl.disableDepthTest();
    pgl.setClearColor(0,0,0,0);
    pgl.clearDepthBuffer();
  }
 else   if (which == ENABLE_DEPTH_TEST) {
    flush();
    pgl.enableDepthTest();
  }
 else   if (which == DISABLE_DEPTH_MASK) {
    flush();
    pgl.disableDepthMask();
  }
 else   if (which == ENABLE_DEPTH_MASK) {
    flush();
    pgl.enableDepthMask();
  }
 else   if (which == DISABLE_ACCURATE_2D) {
    flush();
    setFlushMode(FLUSH_WHEN_FULL);
  }
 else   if (which == ENABLE_ACCURATE_2D) {
    flush();
    setFlushMode(FLUSH_CONTINUOUSLY);
  }
 else   if (which == DISABLE_TEXTURE_CACHE) {
    flush();
  }
 else   if (which == DISABLE_PERSPECTIVE_CORRECTED_LINES) {
    if (0 < tessGeo.lineVertexCount && 0 < tessGeo.lineIndexCount) {
      flush();
    }
  }
 else   if (which == ENABLE_PERSPECTIVE_CORRECTED_LINES) {
    if (0 < tessGeo.lineVertexCount && 0 < tessGeo.lineIndexCount) {
      flush();
    }
  }
}

Fixed version (ground truth):
public void hint(int which){
  boolean oldValue=which > 0 ? hints[which] : hints[-which];
  super.hint(which);
  boolean newValue=which > 0 ? hints[which] : hints[-which];
  if (oldValue == newValue) {
    return;
  }
  if (which == DISABLE_DEPTH_TEST) {
    flush();
    pgl.disableDepthTest();
    pgl.setClearColor(0,0,0,0);
    pgl.clearDepthBuffer();
  }
 else   if (which == ENABLE_DEPTH_TEST) {
    flush();
    pgl.enableDepthTest();
  }
 else   if (which == DISABLE_DEPTH_MASK) {
    flush();
    pgl.disableDepthMask();
  }
 else   if (which == ENABLE_DEPTH_MASK) {
    flush();
    pgl.enableDepthMask();
  }
 else   if (which == DISABLE_ACCURATE_2D) {
    flush();
    setFlushMode(FLUSH_WHEN_FULL);
  }
 else   if (which == ENABLE_ACCURATE_2D) {
    flush();
    setFlushMode(FLUSH_CONTINUOUSLY);
  }
 else   if (which == DISABLE_TEXTURE_CACHE) {
    flush();
  }
 else   if (which == DISABLE_PERSPECTIVE_CORRECTED_LINES) {
    if (0 < tessGeo.lineVertexCount && 0 < tessGeo.lineIndexCount) {
      flush();
    }
  }
 else   if (which == ENABLE_PERSPECTIVE_CORRECTED_LINES) {
    if (0 < tessGeo.lineVertexCount && 0 < tessGeo.lineIndexCount) {
      flush();
    }
  }
}
Program: 109189
Project: 109189
Buggy source:
public void directionalLight(float r,float g,float b,float nx,float ny,float nz){
  if (!lights) {
    enableLighting();
  }
  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;
  lightEnable(lightCount);
  lightNoAmbient(lightCount);
  lightDirection(lightCount);
  lightDiffuse(lightCount);
  lightSpecular(lightCount);
  lightFalloff(lightCount);
  lightNoSpot(lightCount);
  lightCount++;
}

Fixed version (ground truth):
public void directionalLight(float r,float g,float b,float nx,float ny,float nz){
  if (!lights) {
    enableLighting();
  }
  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];
  lightNormal[lightCount][0]=-nx;
  lightNormal[lightCount][1]=-ny;
  lightNormal[lightCount][2]=-nz;
  lightNormal[lightCount][3]=0.0f;
  lightEnable(lightCount);
  lightNoAmbient(lightCount);
  lightDirection(lightCount);
  lightDiffuse(lightCount);
  lightSpecular(lightCount);
  lightFalloff(lightCount);
  lightNoSpot(lightCount);
  lightCount++;
}
Program: 109191
Project: 109191
Buggy source:
/** 
 * Same as glFrustum(), except that it wipes out (rather than multiplies against) the current perspective matrix. <P> Implementation based on the explanation in the OpenGL blue book.
 */
public void frustum(float left,float right,float bottom,float top,float znear,float zfar){
  float temp, temp2, temp3, temp4;
  temp=2.0f * znear;
  temp2=right - left;
  temp3=top - bottom;
  temp4=zfar - znear;
  glprojection[0]=temp / temp2;
  glprojection[1]=0.0f;
  glprojection[2]=0.0f;
  glprojection[3]=0.0f;
  glprojection[4]=0.0f;
  glprojection[5]=temp / temp3;
  glprojection[6]=0.0f;
  glprojection[7]=0.0f;
  glprojection[8]=(right + left) / temp2;
  glprojection[9]=(top + bottom) / temp3;
  glprojection[10]=(-zfar - znear) / temp4;
  glprojection[11]=-1.0f;
  glprojection[12]=0.0f;
  glprojection[13]=0.0f;
  glprojection[14]=(-temp * zfar) / temp4;
  glprojection[15]=0.0f;
  gl.glMatrixMode(GL10.GL_PROJECTION);
  gl.glLoadMatrixf(glprojection,0);
  copyGLArrayToPMatrix(glprojection,projection);
  projectionUpdated=true;
  PApplet.arrayCopy(glprojection,pprojection);
  gl.glMatrixMode(GL10.GL_MODELVIEW);
}

Fixed version (ground truth):
/** 
 * Same as glFrustum(), except that it wipes out (rather than multiplies against) the current perspective matrix. <P> Implementation based on the explanation in the OpenGL blue book.
 */
public void frustum(float left,float right,float bottom,float top,float znear,float zfar){
  float temp, temp2, temp3, temp4;
  temp=2.0f * znear;
  temp2=right - left;
  temp3=top - bottom;
  temp4=zfar - znear;
  glprojection[0]=temp / temp2;
  glprojection[1]=0.0f;
  glprojection[2]=0.0f;
  glprojection[3]=0.0f;
  glprojection[4]=0.0f;
  glprojection[5]=-temp / temp3;
  glprojection[6]=0.0f;
  glprojection[7]=0.0f;
  glprojection[8]=(right + left) / temp2;
  glprojection[9]=(top + bottom) / temp3;
  glprojection[10]=(-zfar - znear) / temp4;
  glprojection[11]=-1.0f;
  glprojection[12]=0.0f;
  glprojection[13]=0.0f;
  glprojection[14]=(-temp * zfar) / temp4;
  glprojection[15]=0.0f;
  gl.glMatrixMode(GL10.GL_PROJECTION);
  gl.glLoadMatrixf(glprojection,0);
  copyGLArrayToPMatrix(glprojection,projection);
  projectionUpdated=true;
  PApplet.arrayCopy(glprojection,pprojection);
  gl.glMatrixMode(GL10.GL_MODELVIEW);
}
Program: 109192
Project: 109192
Buggy source:
public void beginShape(int kind){
  shape=kind;
  if (hints[ENABLE_DEPTH_SORT]) {
    shapeFirst=vertexCount;
    shapeLast=0;
  }
 else {
    vertexCount=0;
    pathCount=0;
    faceCount=0;
    pointCount=0;
    lineCount=0;
    triangleCount=0;
  }
  shapeTextures=0;
  noTexture();
}

Fixed version (ground truth):
public void beginShape(int kind){
  shape=kind;
  if (hints[ENABLE_DEPTH_SORT]) {
    shapeFirst=vertexCount;
    shapeLast=0;
  }
 else {
    vertexCount=0;
    curveVertexCount=0;
    pathCount=0;
    faceCount=0;
    pointCount=0;
    lineCount=0;
    triangleCount=0;
  }
  shapeTextures=0;
  noTexture();
}
Program: 109193
Project: 109193
Buggy source:
public void endDraw(){
  if (primarySurface) {
    Canvas screen=null;
    try {
      screen=parent.getSurfaceHolder().lockCanvas(null);
      if (screen != null) {
        screen.drawBitmap(bitmap,new Matrix(),null);
      }
    }
  finally {
      if (screen != null) {
        parent.getSurfaceHolder().unlockCanvasAndPost(screen);
      }
    }
  }
  if (!primarySurface) {
    loadPixels();
  }
  modified=true;
}

Fixed version (ground truth):
public void endDraw(){
  if (primarySurface) {
    Canvas screen=null;
    try {
      screen=parent.getSurfaceHolder().lockCanvas(null);
      if (screen != null) {
        screen.drawBitmap(bitmap,new Matrix(),null);
      }
    }
  finally {
      if (screen != null) {
        parent.getSurfaceHolder().unlockCanvasAndPost(screen);
      }
    }
  }
 else {
    loadPixels();
  }
  setModified();
  super.updatePixels();
}
Program: 109194
Project: 109194
Buggy source:
public void rect(float a,float b,float c,float d,float tl,float tr,float br,float bl){
  float hradius, vradius;
switch (rectMode) {
case CORNERS:
    break;
case CORNER:
  c+=a;
d+=b;
break;
case RADIUS:
hradius=c;
vradius=d;
c=a + hradius;
d=b + vradius;
a-=hradius;
b-=vradius;
break;
case CENTER:
hradius=c / 2.0f;
vradius=d / 2.0f;
c=a + hradius;
d=b + vradius;
a-=hradius;
b-=vradius;
}
if (a > c) {
float temp=a;
a=c;
c=temp;
}
if (b > d) {
float temp=b;
b=d;
d=temp;
}
rectImpl(a,b,c,d,tl,tr,br,bl);
}

Fixed version (ground truth):
public void rect(float a,float b,float c,float d,float tl,float tr,float br,float bl){
  float hradius, vradius;
switch (rectMode) {
case CORNERS:
    break;
case CORNER:
  c+=a;
d+=b;
break;
case RADIUS:
hradius=c;
vradius=d;
c=a + hradius;
d=b + vradius;
a-=hradius;
b-=vradius;
break;
case CENTER:
hradius=c / 2.0f;
vradius=d / 2.0f;
c=a + hradius;
d=b + vradius;
a-=hradius;
b-=vradius;
}
if (a > c) {
float temp=a;
a=c;
c=temp;
}
if (b > d) {
float temp=b;
b=d;
d=temp;
}
float maxRounding=PApplet.min((c - a) / 2,(d - b) / 2);
if (tl > maxRounding) tl=maxRounding;
if (tr > maxRounding) tr=maxRounding;
if (br > maxRounding) br=maxRounding;
if (bl > maxRounding) bl=maxRounding;
rectImpl(a,b,c,d,tl,tr,br,bl);
}
Program: 109195
Project: 109195
Buggy source:
protected PImage getImpl(int x,int y,int w,int h){
  PImage newbie=parent.createImage(w,h,ARGB);
  PTexture newbieTex=addTexture(newbie);
  IntBuffer newbieBuffer=IntBuffer.allocate(w * h);
  gl.glReadPixels(x,height - y,w,-h,GL10.GL_RGBA,GL10.GL_UNSIGNED_BYTE,newbieBuffer);
  copyToTexture(newbieTex,newbieBuffer,0,0,w,h);
  newbie.loadPixels();
  newbieTex.get(newbie.pixels);
  return newbie;
}

Fixed version (ground truth):
protected PImage getImpl(int x,int y,int w,int h){
  PImage newbie=parent.createImage(w,h,ARGB);
  PTexture newbieTex=addTexture(newbie);
  IntBuffer newbieBuffer=IntBuffer.allocate(w * h);
  boolean nonCurrent=!primarySurface && offscreenFramebuffer != currentFramebuffer;
  if (nonCurrent) {
    pushFramebuffer();
    setFramebuffer(offscreenFramebuffer);
  }
  gl.glReadPixels(x,height - y - h,w,h,GL10.GL_RGBA,GL10.GL_UNSIGNED_BYTE,newbieBuffer);
  if (nonCurrent) {
    popFramebuffer();
  }
  copyToTexture(newbieTex,newbieBuffer,0,0,w,h);
  newbie.loadPixels();
  newbieTex.flippedY=true;
  newbieTex.get(newbie.pixels);
  return newbie;
}
Program: 109196
Project: 109196
Buggy source:
protected void loadTextureImpl(int sampling){
  if (width == 0 || height == 0)   return;
  if (texture == null) {
    PTexture.Parameters params=PTexture.newParameters(ARGB,sampling);
    texture=new PTexture(parent,width,height,params);
    texture.setFlippedY(true);
    this.setCache(a3d,texture);
    this.setParams(a3d,params);
    texCrop=new int[4];
    texCrop[0]=0;
    texCrop[1]=0;
    texCrop[2]=width;
    texCrop[3]=height;
  }
}

Fixed version (ground truth):
protected void loadTextureImpl(int sampling){
  if (width == 0 || height == 0)   return;
  if (texture == null) {
    PTexture.Parameters params=PTexture.newParameters(ARGB,sampling);
    texture=new PTexture(parent,width,height,params);
    texture.setFlippedY(true);
    this.setCache(a3d,texture);
    this.setParams(a3d,params);
    texCrop=new int[4];
    texCrop[0]=0;
    texCrop[1]=height;
    texCrop[2]=width;
    texCrop[3]=-height;
  }
}
Program: 109197
Project: 109197
Buggy source:
/** 
 * Remove the shape with index idx.
 */
public void removeChild(int idx){
  if (idx < childCount) {
    PShape child=children[idx];
    for (int i=idx; i < childCount - 1; i++) {
      children[i]=children[i + 1];
    }
    childCount--;
    if (child.getName() != null && nameTable != null) {
      nameTable.remove(child.getName());
    }
  }
}

Fixed version (ground truth):
/** 
 * Remove the child shape with index idx.
 */
public void removeChild(int idx){
  if (idx < childCount) {
    PShape child=children[idx];
    for (int i=idx; i < childCount - 1; i++) {
      children[i]=children[i + 1];
    }
    childCount--;
    if (child.getName() != null && nameTable != null) {
      nameTable.remove(child.getName());
    }
  }
}