Program: 25731
Project: 25731
Buggy source:
/** 
 * Inserts bytecode at the specified line in the body. <p>If there is not a statement at the specified line, the bytecode might be inserted at the line including the first statement after that line specified. For example, if there is only a closing brace at that line, the bytecode would be inserted at another line below. To know exactly where the bytecode will be inserted, call with <code>modify</code> set to <code>false</code>. 
 * @param lineNum   the line number.  The bytecode is inserted at thebeginning of the code at the line specified by this line number.
 * @param modify    if false, this method does not insert the bytecode.It instead only returns the line number at which the bytecode would be inserted.
 * @param src       the source code representing the inserted bytecode.It must be a single statement or block. If modify is false, the value of src can be null.
 * @return      the line number at which the bytecode has been inserted.
 */
public int insertAt(int lineNum,boolean modify,String src) throws CannotCompileException {
  CodeAttribute ca=methodInfo.getCodeAttribute();
  if (ca == null)   throw new CannotCompileException("String_Node_Str");
  LineNumberAttribute ainfo=(LineNumberAttribute)ca.getAttribute(LineNumberAttribute.tag);
  if (ainfo == null)   throw new CannotCompileException("String_Node_Str");
  LineNumberAttribute.Pc pc=ainfo.toNearPc(lineNum);
  lineNum=pc.line;
  int index=pc.index;
  if (!modify)   return lineNum;
  declaringClass.checkModify();
  CodeIterator iterator=ca.iterator();
  Javac jv=new Javac(declaringClass);
  try {
    jv.recordLocalVariables(ca,index);
    jv.recordParams(getParameterTypes(),Modifier.isStatic(getModifiers()));
    jv.setMaxLocals(ca.getMaxLocals());
    jv.compileStmnt(src);
    Bytecode b=jv.getBytecode();
    int locals=b.getMaxLocals();
    int stack=b.getMaxStack();
    ca.setMaxLocals(locals);
    if (stack > ca.getMaxStack())     ca.setMaxStack(stack);
    iterator.insert(index,b.get());
    iterator.insert(b.getExceptionTable(),index);
    return lineNum;
  }
 catch (  NotFoundException e) {
    throw new CannotCompileException(e);
  }
catch (  CompileError e) {
    throw new CannotCompileException(e);
  }
catch (  BadBytecode e) {
    throw new CannotCompileException(e);
  }
}

Fixed version (ground truth):
/** 
 * Inserts bytecode at the specified line in the body. <p>If there is not a statement at the specified line, the bytecode might be inserted at the line including the first statement after that line specified. For example, if there is only a closing brace at that line, the bytecode would be inserted at another line below. To know exactly where the bytecode will be inserted, call with <code>modify</code> set to <code>false</code>. 
 * @param lineNum   the line number.  The bytecode is inserted at thebeginning of the code at the line specified by this line number.
 * @param modify    if false, this method does not insert the bytecode.It instead only returns the line number at which the bytecode would be inserted.
 * @param src       the source code representing the inserted bytecode.It must be a single statement or block. If modify is false, the value of src can be null.
 * @return      the line number at which the bytecode has been inserted.
 */
public int insertAt(int lineNum,boolean modify,String src) throws CannotCompileException {
  CodeAttribute ca=methodInfo.getCodeAttribute();
  if (ca == null)   throw new CannotCompileException("String_Node_Str");
  LineNumberAttribute ainfo=(LineNumberAttribute)ca.getAttribute(LineNumberAttribute.tag);
  if (ainfo == null)   throw new CannotCompileException("String_Node_Str");
  LineNumberAttribute.Pc pc=ainfo.toNearPc(lineNum);
  lineNum=pc.line;
  int index=pc.index;
  if (!modify)   return lineNum;
  CtClass cc=declaringClass;
  cc.checkModify();
  CodeIterator iterator=ca.iterator();
  Javac jv=new Javac(cc);
  try {
    jv.recordLocalVariables(ca,index);
    jv.recordParams(getParameterTypes(),Modifier.isStatic(getModifiers()));
    jv.setMaxLocals(ca.getMaxLocals());
    jv.compileStmnt(src);
    Bytecode b=jv.getBytecode();
    int locals=b.getMaxLocals();
    int stack=b.getMaxStack();
    ca.setMaxLocals(locals);
    if (stack > ca.getMaxStack())     ca.setMaxStack(stack);
    iterator.insert(index,b.get());
    iterator.insert(b.getExceptionTable(),index);
    methodInfo.rebuildStackMapIf6(cc.getClassPool(),cc.getClassFile2());
    return lineNum;
  }
 catch (  NotFoundException e) {
    throw new CannotCompileException(e);
  }
catch (  CompileError e) {
    throw new CannotCompileException(e);
  }
catch (  BadBytecode e) {
    throw new CannotCompileException(e);
  }
}