Program: 25719
Project: 25719
Buggy source:
/** 
 * Replaces the method call with the bytecode derived from the given source text. <p>$0 is available even if the called method is static.
 * @param statement         a Java statement.
 */
public void replace(String statement) throws CannotCompileException {
  ConstPool constPool=getConstPool();
  int pos=currentPos;
  int index=iterator.u16bitAt(pos + 1);
  String classname, methodname, signature;
  int opcodeSize;
  int c=iterator.byteAt(pos);
  if (c == INVOKEINTERFACE) {
    opcodeSize=5;
    classname=constPool.getInterfaceMethodrefClassName(index);
    methodname=constPool.getInterfaceMethodrefName(index);
    signature=constPool.getInterfaceMethodrefType(index);
  }
 else   if (c == INVOKESTATIC || c == INVOKESPECIAL || c == INVOKEVIRTUAL) {
    opcodeSize=3;
    classname=constPool.getMethodrefClassName(index);
    methodname=constPool.getMethodrefName(index);
    signature=constPool.getMethodrefType(index);
  }
 else   throw new CannotCompileException("String_Node_Str");
  Javac jc=new Javac(thisClass);
  ClassPool cp=thisClass.getClassPool();
  CodeAttribute ca=iterator.get();
  try {
    CtClass[] params=Descriptor.getParameterTypes(signature,cp);
    CtClass retType=Descriptor.getReturnType(signature,cp);
    int paramVar=ca.getMaxLocals();
    jc.recordParams(classname,params,true,paramVar,withinStatic());
    int retVar=jc.recordReturnType(retType,true);
    if (c == INVOKESTATIC)     jc.recordStaticProceed(classname,methodname);
 else     if (c == INVOKESPECIAL)     jc.recordSpecialProceed(Javac.param0Name,classname,methodname,signature);
 else     jc.recordProceed(Javac.param0Name,methodname);
    checkResultValue(retType,statement);
    Bytecode bytecode=jc.getBytecode();
    storeStack(params,c == INVOKESTATIC,paramVar,bytecode);
    jc.recordLocalVariables(ca,pos);
    if (retType != CtClass.voidType) {
      bytecode.addConstZero(retType);
      bytecode.addStore(retVar,retType);
    }
    jc.compileStmnt(statement);
    if (retType != CtClass.voidType)     bytecode.addLoad(retVar,retType);
    replace0(pos,bytecode,opcodeSize);
  }
 catch (  CompileError e) {
    throw new CannotCompileException(e);
  }
catch (  NotFoundException e) {
    throw new CannotCompileException(e);
  }
catch (  BadBytecode e) {
    throw new CannotCompileException("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Replaces the method call with the bytecode derived from the given source text. <p>$0 is available even if the called method is static.
 * @param statement         a Java statement.
 */
public void replace(String statement) throws CannotCompileException {
  thisClass.getClassFile();
  ConstPool constPool=getConstPool();
  int pos=currentPos;
  int index=iterator.u16bitAt(pos + 1);
  String classname, methodname, signature;
  int opcodeSize;
  int c=iterator.byteAt(pos);
  if (c == INVOKEINTERFACE) {
    opcodeSize=5;
    classname=constPool.getInterfaceMethodrefClassName(index);
    methodname=constPool.getInterfaceMethodrefName(index);
    signature=constPool.getInterfaceMethodrefType(index);
  }
 else   if (c == INVOKESTATIC || c == INVOKESPECIAL || c == INVOKEVIRTUAL) {
    opcodeSize=3;
    classname=constPool.getMethodrefClassName(index);
    methodname=constPool.getMethodrefName(index);
    signature=constPool.getMethodrefType(index);
  }
 else   throw new CannotCompileException("String_Node_Str");
  Javac jc=new Javac(thisClass);
  ClassPool cp=thisClass.getClassPool();
  CodeAttribute ca=iterator.get();
  try {
    CtClass[] params=Descriptor.getParameterTypes(signature,cp);
    CtClass retType=Descriptor.getReturnType(signature,cp);
    int paramVar=ca.getMaxLocals();
    jc.recordParams(classname,params,true,paramVar,withinStatic());
    int retVar=jc.recordReturnType(retType,true);
    if (c == INVOKESTATIC)     jc.recordStaticProceed(classname,methodname);
 else     if (c == INVOKESPECIAL)     jc.recordSpecialProceed(Javac.param0Name,classname,methodname,signature);
 else     jc.recordProceed(Javac.param0Name,methodname);
    checkResultValue(retType,statement);
    Bytecode bytecode=jc.getBytecode();
    storeStack(params,c == INVOKESTATIC,paramVar,bytecode);
    jc.recordLocalVariables(ca,pos);
    if (retType != CtClass.voidType) {
      bytecode.addConstZero(retType);
      bytecode.addStore(retVar,retType);
    }
    jc.compileStmnt(statement);
    if (retType != CtClass.voidType)     bytecode.addLoad(retVar,retType);
    replace0(pos,bytecode,opcodeSize);
  }
 catch (  CompileError e) {
    throw new CannotCompileException(e);
  }
catch (  NotFoundException e) {
    throw new CannotCompileException(e);
  }
catch (  BadBytecode e) {
    throw new CannotCompileException("String_Node_Str");
  }
}