Program: 25732
Project: 25732
Buggy source:
/** 
 * Inserts bytecode at the end of the body. The bytecode is inserted just before every return insturction.
 * @param src       the source code representing the inserted bytecode.It must be a single statement or block.
 * @param asFinally         true if the inserted bytecode is executednot only when the control normally returns but also when an exception is thrown. If this parameter is true, the inserted code cannot access local variables.
 */
public void insertAfter(String src,boolean asFinally) throws CannotCompileException {
  declaringClass.checkModify();
  ConstPool pool=methodInfo.getConstPool();
  CodeAttribute ca=methodInfo.getCodeAttribute();
  if (ca == null)   throw new CannotCompileException("String_Node_Str");
  CodeIterator iterator=ca.iterator();
  int retAddr=ca.getMaxLocals();
  Bytecode b=new Bytecode(pool,0,retAddr + 1);
  b.setStackDepth(ca.getMaxStack() + 1);
  Javac jv=new Javac(b,declaringClass);
  try {
    int nvars=jv.recordParams(getParameterTypes(),Modifier.isStatic(getModifiers()));
    jv.recordParamNames(ca,nvars);
    CtClass rtype=getReturnType0();
    int varNo=jv.recordReturnType(rtype,true);
    jv.recordLocalVariables(ca,0);
    int handlerLen=insertAfterHandler(asFinally,b,rtype,varNo,jv,src);
    insertAfterAdvice(b,jv,src,pool,rtype,varNo);
    ca.setMaxStack(b.getMaxStack());
    ca.setMaxLocals(b.getMaxLocals());
    int gapPos=iterator.append(b.get());
    iterator.append(b.getExceptionTable(),gapPos);
    if (asFinally)     ca.getExceptionTable().add(0,gapPos,gapPos,0);
    int gapLen=iterator.getCodeLength() - gapPos - handlerLen;
    int subr=iterator.getCodeLength() - gapLen;
    while (iterator.hasNext()) {
      int pos=iterator.next();
      if (pos >= subr)       break;
      int c=iterator.byteAt(pos);
      if (c == Opcode.ARETURN || c == Opcode.IRETURN || c == Opcode.FRETURN || c == Opcode.LRETURN || c == Opcode.DRETURN || c == Opcode.RETURN) {
        insertGoto(iterator,subr,pos);
        subr=iterator.getCodeLength() - gapLen;
      }
    }
  }
 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 end of the body. The bytecode is inserted just before every return insturction.
 * @param src       the source code representing the inserted bytecode.It must be a single statement or block.
 * @param asFinally         true if the inserted bytecode is executednot only when the control normally returns but also when an exception is thrown. If this parameter is true, the inserted code cannot access local variables.
 */
public void insertAfter(String src,boolean asFinally) throws CannotCompileException {
  CtClass cc=declaringClass;
  cc.checkModify();
  ConstPool pool=methodInfo.getConstPool();
  CodeAttribute ca=methodInfo.getCodeAttribute();
  if (ca == null)   throw new CannotCompileException("String_Node_Str");
  CodeIterator iterator=ca.iterator();
  int retAddr=ca.getMaxLocals();
  Bytecode b=new Bytecode(pool,0,retAddr + 1);
  b.setStackDepth(ca.getMaxStack() + 1);
  Javac jv=new Javac(b,cc);
  try {
    int nvars=jv.recordParams(getParameterTypes(),Modifier.isStatic(getModifiers()));
    jv.recordParamNames(ca,nvars);
    CtClass rtype=getReturnType0();
    int varNo=jv.recordReturnType(rtype,true);
    jv.recordLocalVariables(ca,0);
    int handlerLen=insertAfterHandler(asFinally,b,rtype,varNo,jv,src);
    insertAfterAdvice(b,jv,src,pool,rtype,varNo);
    ca.setMaxStack(b.getMaxStack());
    ca.setMaxLocals(b.getMaxLocals());
    int gapPos=iterator.append(b.get());
    iterator.append(b.getExceptionTable(),gapPos);
    if (asFinally)     ca.getExceptionTable().add(0,gapPos,gapPos,0);
    int gapLen=iterator.getCodeLength() - gapPos - handlerLen;
    int subr=iterator.getCodeLength() - gapLen;
    while (iterator.hasNext()) {
      int pos=iterator.next();
      if (pos >= subr)       break;
      int c=iterator.byteAt(pos);
      if (c == Opcode.ARETURN || c == Opcode.IRETURN || c == Opcode.FRETURN || c == Opcode.LRETURN || c == Opcode.DRETURN || c == Opcode.RETURN) {
        insertGoto(iterator,subr,pos);
        subr=iterator.getCodeLength() - gapLen;
      }
    }
    methodInfo.rebuildStackMapIf6(cc.getClassPool(),cc.getClassFile2());
  }
 catch (  NotFoundException e) {
    throw new CannotCompileException(e);
  }
catch (  CompileError e) {
    throw new CannotCompileException(e);
  }
catch (  BadBytecode e) {
    throw new CannotCompileException(e);
  }
}