nus-yam/ex-repair huggingface dataset:
Program: 25730
Project: 25730
Buggy source:
/** 
 * Declares to use <code>$cflow</code> for this method/constructor. If <code>$cflow</code> is used, the class files modified with Javassist requires a support class <code>javassist.runtime.Cflow</code> at runtime (other Javassist classes are not required at runtime). <p>Every <code>$cflow</code> variable is given a unique name. For example, if the given name is <code>"Point.paint"</code>, then the variable is indicated by <code>$cflow(Point.paint)</code>.
 * @param name      <code>$cflow</code> name.  It can includealphabets, numbers, <code>_</code>, <code>$</code>, and <code>.</code> (dot).
 * @see javassist.runtime.Cflow
 */
public void useCflow(String name) throws CannotCompileException {
  CtClass cc=declaringClass;
  cc.checkModify();
  ClassPool pool=cc.getClassPool();
  String fname;
  int i=0;
  while (true) {
    fname="String_Node_Str" + i++;
    try {
      cc.getDeclaredField(fname);
    }
 catch (    NotFoundException e) {
      break;
    }
  }
  pool.recordCflow(name,declaringClass.getName(),fname);
  try {
    CtClass type=pool.get("String_Node_Str");
    CtField field=new CtField(type,fname,cc);
    field.setModifiers(Modifier.PUBLIC | Modifier.STATIC);
    cc.addField(field,CtField.Initializer.byNew(type));
    insertBefore(fname + "String_Node_Str");
    String src=fname + "String_Node_Str";
    insertAfter(src,true);
  }
 catch (  NotFoundException e) {
    throw new CannotCompileException(e);
  }
}

Fixed version (ground truth):
/** 
 * Declares to use <code>$cflow</code> for this method/constructor. If <code>$cflow</code> is used, the class files modified with Javassist requires a support class <code>javassist.runtime.Cflow</code> at runtime (other Javassist classes are not required at runtime). <p>Every <code>$cflow</code> variable is given a unique name. For example, if the given name is <code>"Point.paint"</code>, then the variable is indicated by <code>$cflow(Point.paint)</code>.
 * @param name      <code>$cflow</code> name.  It can includealphabets, numbers, <code>_</code>, <code>$</code>, and <code>.</code> (dot).
 * @see javassist.runtime.Cflow
 */
public void useCflow(String name) throws CannotCompileException {
  CtClass cc=declaringClass;
  cc.checkModify();
  ClassPool pool=cc.getClassPool();
  String fname;
  int i=0;
  while (true) {
    fname="String_Node_Str" + i++;
    try {
      cc.getDeclaredField(fname);
    }
 catch (    NotFoundException e) {
      break;
    }
  }
  pool.recordCflow(name,declaringClass.getName(),fname);
  try {
    CtClass type=pool.get("String_Node_Str");
    CtField field=new CtField(type,fname,cc);
    field.setModifiers(Modifier.PUBLIC | Modifier.STATIC);
    cc.addField(field,CtField.Initializer.byNew(type));
    insertBefore(fname + "String_Node_Str",false);
    String src=fname + "String_Node_Str";
    insertAfter(src,true);
  }
 catch (  NotFoundException e) {
    throw new CannotCompileException(e);
  }
}
Program: 25733
Project: 25733
Buggy source:
/** 
 * Inserts bytecode at the beginning of the body. <p>If this object represents a constructor, the bytecode is inserted before a constructor in the super class or this class is called. Therefore, the inserted bytecode is subject to constraints described in Section 4.8.2 of The Java Virtual Machine Specification (2nd ed). For example, it cannot access instance fields or methods although it may assign a value to an instance field directly declared in this class.  Accessing static fields and methods is allowed. Use <code>insertBeforeBody()</code> in <code>CtConstructor</code>.
 * @param src       the source code representing the inserted bytecode.It must be a single statement or block.
 * @see CtConstructor#insertBeforeBody(String)
 */
public void insertBefore(String src) throws CannotCompileException {
  declaringClass.checkModify();
  CodeAttribute ca=methodInfo.getCodeAttribute();
  if (ca == null)   throw new CannotCompileException("String_Node_Str");
  CodeIterator iterator=ca.iterator();
  Javac jv=new Javac(declaringClass);
  try {
    int nvars=jv.recordParams(getParameterTypes(),Modifier.isStatic(getModifiers()));
    jv.recordParamNames(ca,nvars);
    jv.recordLocalVariables(ca,0);
    jv.compileStmnt(src);
    Bytecode b=jv.getBytecode();
    int stack=b.getMaxStack();
    int locals=b.getMaxLocals();
    if (stack > ca.getMaxStack())     ca.setMaxStack(stack);
    if (locals > ca.getMaxLocals())     ca.setMaxLocals(locals);
    int pos=iterator.insertEx(b.get());
    iterator.insert(b.getExceptionTable(),pos);
  }
 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):
private void insertBefore(String src,boolean rebuild) throws CannotCompileException {
  CtClass cc=declaringClass;
  cc.checkModify();
  CodeAttribute ca=methodInfo.getCodeAttribute();
  if (ca == null)   throw new CannotCompileException("String_Node_Str");
  CodeIterator iterator=ca.iterator();
  Javac jv=new Javac(cc);
  try {
    int nvars=jv.recordParams(getParameterTypes(),Modifier.isStatic(getModifiers()));
    jv.recordParamNames(ca,nvars);
    jv.recordLocalVariables(ca,0);
    jv.compileStmnt(src);
    Bytecode b=jv.getBytecode();
    int stack=b.getMaxStack();
    int locals=b.getMaxLocals();
    if (stack > ca.getMaxStack())     ca.setMaxStack(stack);
    if (locals > ca.getMaxLocals())     ca.setMaxLocals(locals);
    int pos=iterator.insertEx(b.get());
    iterator.insert(b.getExceptionTable(),pos);
    if (rebuild)     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);
  }
}
Program: 25735
Project: 25735
Buggy source:
/** 
 * Sets a method/constructor body.
 * @param src       the source code representing the body.It must be a single statement or block. If it is <code>null</code>, the substituted body does nothing except returning zero or null.
 * @param delegateObj       the source text specifying the objectthat is called on by <code>$proceed()</code>.
 * @param delegateMethod    the name of the methodthat is called by <code>$proceed()</code>.
 */
public void setBody(String src,String delegateObj,String delegateMethod) throws CannotCompileException {
  declaringClass.checkModify();
  try {
    Javac jv=new Javac(declaringClass);
    if (delegateMethod != null)     jv.recordProceed(delegateObj,delegateMethod);
    Bytecode b=jv.compileBody(this,src);
    methodInfo.setCodeAttribute(b.toCodeAttribute());
    methodInfo.setAccessFlags(methodInfo.getAccessFlags() & ~AccessFlag.ABSTRACT);
  }
 catch (  CompileError e) {
    throw new CannotCompileException(e);
  }
}

Fixed version (ground truth):
/** 
 * Sets a method/constructor body.
 * @param src       the source code representing the body.It must be a single statement or block. If it is <code>null</code>, the substituted body does nothing except returning zero or null.
 * @param delegateObj       the source text specifying the objectthat is called on by <code>$proceed()</code>.
 * @param delegateMethod    the name of the methodthat is called by <code>$proceed()</code>.
 */
public void setBody(String src,String delegateObj,String delegateMethod) throws CannotCompileException {
  CtClass cc=declaringClass;
  cc.checkModify();
  try {
    Javac jv=new Javac(cc);
    if (delegateMethod != null)     jv.recordProceed(delegateObj,delegateMethod);
    Bytecode b=jv.compileBody(this,src);
    methodInfo.setCodeAttribute(b.toCodeAttribute());
    methodInfo.setAccessFlags(methodInfo.getAccessFlags() & ~AccessFlag.ABSTRACT);
    methodInfo.rebuildStackMapIf6(cc.getClassPool(),cc.getClassFile2());
  }
 catch (  CompileError e) {
    throw new CannotCompileException(e);
  }
catch (  BadBytecode e) {
    throw new CannotCompileException(e);
  }
}
Program: 25736
Project: 25736
Buggy source:
private void modifyConstructors(ClassFile cf) throws CannotCompileException, NotFoundException {
  if (fieldInitializers == null)   return;
  ConstPool cp=cf.getConstPool();
  List list=cf.getMethods();
  int n=list.size();
  for (int i=0; i < n; ++i) {
    MethodInfo minfo=(MethodInfo)list.get(i);
    if (minfo.isConstructor()) {
      CodeAttribute codeAttr=minfo.getCodeAttribute();
      if (codeAttr != null)       try {
        Bytecode init=new Bytecode(cp,0,codeAttr.getMaxLocals());
        CtClass[] params=Descriptor.getParameterTypes(minfo.getDescriptor(),classPool);
        int stacksize=makeFieldInitializer(init,params);
        insertAuxInitializer(codeAttr,init,stacksize);
      }
 catch (      BadBytecode e) {
        throw new CannotCompileException(e);
      }
    }
  }
}

Fixed version (ground truth):
private void modifyConstructors(ClassFile cf) throws CannotCompileException, NotFoundException {
  if (fieldInitializers == null)   return;
  ConstPool cp=cf.getConstPool();
  List list=cf.getMethods();
  int n=list.size();
  for (int i=0; i < n; ++i) {
    MethodInfo minfo=(MethodInfo)list.get(i);
    if (minfo.isConstructor()) {
      CodeAttribute codeAttr=minfo.getCodeAttribute();
      if (codeAttr != null)       try {
        Bytecode init=new Bytecode(cp,0,codeAttr.getMaxLocals());
        CtClass[] params=Descriptor.getParameterTypes(minfo.getDescriptor(),classPool);
        int stacksize=makeFieldInitializer(init,params);
        insertAuxInitializer(codeAttr,init,stacksize);
        minfo.rebuildStackMapIf6(classPool,cf);
      }
 catch (      BadBytecode e) {
        throw new CannotCompileException(e);
      }
    }
  }
}
Program: 25737
Project: 25737
Buggy source:
private void modifyClassConstructor(ClassFile cf,Bytecode code,int stacksize,int localsize) throws CannotCompileException {
  MethodInfo m=cf.getStaticInitializer();
  if (m == null) {
    code.add(Bytecode.RETURN);
    code.setMaxStack(stacksize);
    code.setMaxLocals(localsize);
    m=new MethodInfo(cf.getConstPool(),"String_Node_Str","String_Node_Str");
    m.setAccessFlags(AccessFlag.STATIC);
    m.setCodeAttribute(code.toCodeAttribute());
    cf.addMethod(m);
  }
 else {
    CodeAttribute codeAttr=m.getCodeAttribute();
    if (codeAttr == null)     throw new CannotCompileException("String_Node_Str");
    try {
      CodeIterator it=codeAttr.iterator();
      int pos=it.insertEx(code.get());
      it.insert(code.getExceptionTable(),pos);
      int maxstack=codeAttr.getMaxStack();
      if (maxstack < stacksize)       codeAttr.setMaxStack(stacksize);
      int maxlocals=codeAttr.getMaxLocals();
      if (maxlocals < localsize)       codeAttr.setMaxLocals(localsize);
    }
 catch (    BadBytecode e) {
      throw new CannotCompileException(e);
    }
  }
}

Fixed version (ground truth):
private void modifyClassConstructor(ClassFile cf,Bytecode code,int stacksize,int localsize) throws CannotCompileException {
  MethodInfo m=cf.getStaticInitializer();
  if (m == null) {
    code.add(Bytecode.RETURN);
    code.setMaxStack(stacksize);
    code.setMaxLocals(localsize);
    m=new MethodInfo(cf.getConstPool(),"String_Node_Str","String_Node_Str");
    m.setAccessFlags(AccessFlag.STATIC);
    m.setCodeAttribute(code.toCodeAttribute());
    cf.addMethod(m);
  }
 else {
    CodeAttribute codeAttr=m.getCodeAttribute();
    if (codeAttr == null)     throw new CannotCompileException("String_Node_Str");
    try {
      CodeIterator it=codeAttr.iterator();
      int pos=it.insertEx(code.get());
      it.insert(code.getExceptionTable(),pos);
      int maxstack=codeAttr.getMaxStack();
      if (maxstack < stacksize)       codeAttr.setMaxStack(stacksize);
      int maxlocals=codeAttr.getMaxLocals();
      if (maxlocals < localsize)       codeAttr.setMaxLocals(localsize);
    }
 catch (    BadBytecode e) {
      throw new CannotCompileException(e);
    }
  }
  try {
    m.rebuildStackMapIf6(classPool,cf);
  }
 catch (  BadBytecode e) {
    throw new CannotCompileException(e);
  }
}
Program: 25738
Project: 25738
Buggy source:
/** 
 * Inserts bytecode just after another constructor in the super class or this class is called. It does not work if this object represents a class initializer.
 * @param src       the source code representing the inserted bytecode.It must be a single statement or block.
 */
public void insertBeforeBody(String src) throws CannotCompileException {
  declaringClass.checkModify();
  if (isClassInitializer())   throw new CannotCompileException("String_Node_Str");
  CodeAttribute ca=methodInfo.getCodeAttribute();
  CodeIterator iterator=ca.iterator();
  Bytecode b=new Bytecode(methodInfo.getConstPool(),ca.getMaxStack(),ca.getMaxLocals());
  b.setStackDepth(ca.getMaxStack());
  Javac jv=new Javac(b,declaringClass);
  try {
    jv.recordParams(getParameterTypes(),false);
    jv.compileStmnt(src);
    ca.setMaxStack(b.getMaxStack());
    ca.setMaxLocals(b.getMaxLocals());
    iterator.skipConstructor();
    int pos=iterator.insertEx(b.get());
    iterator.insert(b.getExceptionTable(),pos);
  }
 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 just after another constructor in the super class or this class is called. It does not work if this object represents a class initializer.
 * @param src       the source code representing the inserted bytecode.It must be a single statement or block.
 */
public void insertBeforeBody(String src) throws CannotCompileException {
  CtClass cc=declaringClass;
  cc.checkModify();
  if (isClassInitializer())   throw new CannotCompileException("String_Node_Str");
  CodeAttribute ca=methodInfo.getCodeAttribute();
  CodeIterator iterator=ca.iterator();
  Bytecode b=new Bytecode(methodInfo.getConstPool(),ca.getMaxStack(),ca.getMaxLocals());
  b.setStackDepth(ca.getMaxStack());
  Javac jv=new Javac(b,cc);
  try {
    jv.recordParams(getParameterTypes(),false);
    jv.compileStmnt(src);
    ca.setMaxStack(b.getMaxStack());
    ca.setMaxLocals(b.getMaxLocals());
    iterator.skipConstructor();
    int pos=iterator.insertEx(b.get());
    iterator.insert(b.getExceptionTable(),pos);
    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);
  }
}
Program: 25740
Project: 25740
Buggy source:
private boolean notBridgeMethod(MethodInfo minfo){
  return (minfo.getAccessFlags() & AccessFlag.BRIDGE) == 0;
}

Fixed version (ground truth):
private static boolean notBridgeMethod(MethodInfo minfo){
  return (minfo.getAccessFlags() & AccessFlag.BRIDGE) == 0;
}
Program: 25741
Project: 25741
Buggy source:
/** 
 * Appends a method to the class.
 * @throws DuplicateMemberException         when the method is already included.
 */
public void addMethod(MethodInfo minfo) throws DuplicateMemberException {
  testExistingMethod(minfo);
  methods.add(minfo);
}

Fixed version (ground truth):
/** 
 * Appends a method to the class. If there is a bridge method with the same name and signature, then the bridge method is removed before a new method is added.
 * @throws DuplicateMemberException         when the method is already included.
 */
public void addMethod(MethodInfo minfo) throws DuplicateMemberException {
  testExistingMethod(minfo);
  methods.add(minfo);
}
Program: 25742
Project: 25742
Buggy source:
private void testExistingMethod(MethodInfo newMinfo) throws DuplicateMemberException {
  String name=newMinfo.getName();
  String descriptor=newMinfo.getDescriptor();
  ListIterator it=methods.listIterator(0);
  while (it.hasNext()) {
    MethodInfo minfo=(MethodInfo)it.next();
    if (minfo.getName().equals(name) && notBridgeMethod(minfo) && notBridgeMethod(newMinfo)&& Descriptor.eqParamTypes(minfo.getDescriptor(),descriptor))     throw new DuplicateMemberException("String_Node_Str" + name + "String_Node_Str"+ this.getName());
  }
}

Fixed version (ground truth):
private void testExistingMethod(MethodInfo newMinfo) throws DuplicateMemberException {
  String name=newMinfo.getName();
  String descriptor=newMinfo.getDescriptor();
  ListIterator it=methods.listIterator(0);
  while (it.hasNext())   if (isDuplicated(newMinfo,name,descriptor,(MethodInfo)it.next(),it))   throw new DuplicateMemberException("String_Node_Str" + name + "String_Node_Str"+ this.getName());
}
Program: 25743
Project: 25743
Buggy source:
/** 
 * Writes a <code>append_frame</code>.
 * @param tag           <code>locals[].tag</code>.The length of this array must be either 1, 2, or 3.
 * @param data          <code>locals[].cpool_index</code>if the tag is <code>OBJECT</code>, or <cod>locals[].offset</code> if the tag is <code>UNINIT</code>. Otherwise, this parameter is not used.
 */
public void appendFrame(int offsetDelta,int[] tags,int[] data){
  numOfEntries++;
  int k=tags.length;
  output.write(k + 251);
  write16(offsetDelta);
  for (int i=0; i < k; i++)   writeTypeInfo(tags[i],data[i]);
}

Fixed version (ground truth):
public void appendFrame(int pos,int offsetDelta,int[] tags,int[] data){
  writer.println("String_Node_Str" + offsetDelta);
  for (int i=0; i < tags.length; i++)   printTypeInfo(tags[i],data[i]);
}
Program: 25744
Project: 25744
Buggy source:
/** 
 * Writes a <code>same_frame</code> or a <code>same_frame_extended</code>.
 */
public void sameFrame(int offsetDelta){
  numOfEntries++;
  if (offsetDelta < 64)   output.write(offsetDelta);
 else {
    output.write(251);
    write16(offsetDelta);
  }
}

Fixed version (ground truth):
public void sameFrame(int pos,int offsetDelta){
  writer.println("String_Node_Str" + offsetDelta);
}
Program: 25745
Project: 25745
Buggy source:
/** 
 * Writes a <code>same_locals_1_stack_item</code> or a <code>same_locals_1_stack_item_extended</code>.
 * @param tag           <code>stack[0].tag</code>.
 * @param data          <code>stack[0].cpool_index</code>if the tag is <code>OBJECT</code>, or <cod>stack[0].offset</code> if the tag is <code>UNINIT</code>. Otherwise, this parameter is not used.
 */
public void sameLocals(int offsetDelta,int tag,int data){
  numOfEntries++;
  if (offsetDelta < 64)   output.write(offsetDelta + 64);
 else {
    output.write(247);
    write16(offsetDelta);
  }
  writeTypeInfo(tag,data);
}

Fixed version (ground truth):
public void sameLocals(int pos,int offsetDelta,int stackTag,int stackData){
  writer.println("String_Node_Str" + offsetDelta);
  printTypeInfo(stackTag,stackData);
}
Program: 25746
Project: 25746
Buggy source:
/** 
 * Writes a <code>chop_frame</code>.
 * @param k                 the number of absent locals. 1, 2, or 3.
 */
public void chopFrame(int offsetDelta,int k){
  numOfEntries++;
  output.write(251 - k);
  write16(offsetDelta);
}

Fixed version (ground truth):
public void chopFrame(int pos,int offsetDelta,int k){
  writer.println("String_Node_Str" + offsetDelta + "String_Node_Str"+ k+ "String_Node_Str");
}
Program: 25747
Project: 25747
Buggy source:
/** 
 * Writes a <code>full_frame</code>.
 * @param localTags     <code>locals[].tag</code>.
 * @param localData     <code>locals[].cpool_index</code>if the tag is <code>OBJECT</code>, or <cod>locals[].offset</code> if the tag is <code>UNINIT</code>. Otherwise, this parameter is not used.
 * @param stackTags     <code>stack[].tag</code>.
 * @param stackData     <code>stack[].cpool_index</code>if the tag is <code>OBJECT</code>, or <cod>stack[].offset</code> if the tag is <code>UNINIT</code>. Otherwise, this parameter is not used.
 */
public void fullFrame(int offsetDelta,int[] localTags,int[] localData,int[] stackTags,int[] stackData){
  numOfEntries++;
  output.write(255);
  write16(offsetDelta);
  int n=localTags.length;
  write16(n);
  for (int i=0; i < n; i++)   writeTypeInfo(localTags[i],localData[i]);
  n=stackTags.length;
  for (int i=0; i < n; i++)   writeTypeInfo(stackTags[i],stackData[i]);
}

Fixed version (ground truth):
public void fullFrame(int pos,int offsetDelta,int[] localTags,int[] localData,int[] stackTags,int[] stackData){
  writer.println("String_Node_Str" + offsetDelta);
  writer.println("String_Node_Str");
  for (int i=0; i < localTags.length; i++)   printTypeInfo(localTags[i],localData[i]);
  writer.println("String_Node_Str");
  for (int i=0; i < stackTags.length; i++)   printTypeInfo(stackTags[i],stackData[i]);
}
Program: 25748
Project: 25748
Buggy source:
/** 
 * Makes a copy.
 */
public AttributeInfo copy(ConstPool newCp,Map classnames){
  int s=info.length;
  byte[] newInfo=new byte[s];
  System.arraycopy(info,0,newInfo,0,s);
  return new StackMapTable(newCp,newInfo);
}

Fixed version (ground truth):
/** 
 * Makes a copy.
 * @exception RuntimeCopyException  if a <code>BadBytecode</code>exception is thrown, it is converted into <code>RuntimeCopyException</code>.
 */
public AttributeInfo copy(ConstPool newCp,Map classnames) throws RuntimeCopyException {
  try {
    return new StackMapTable(newCp,new Copier(this.constPool,info,newCp).doit());
  }
 catch (  BadBytecode e) {
    throw new RuntimeCopyException("String_Node_Str");
  }
}
Program: 25749
Project: 25749
Buggy source:
/** 
 * Maps a class name to another name in this hashtable. This method translates the given class names into the internal form used in the JVM before putting it in the hashtable.
 * @param oldname   the original class name
 * @param newname   the substituted class name.
 */
public void put(String oldname,String newname){
  if (oldname == newname)   return;
  String oldname2=toJvmName(oldname);
  String s=(String)get(oldname2);
  if (s == null || !s.equals(oldname2))   super.put(oldname2,toJvmName(newname));
}

Fixed version (ground truth):
/** 
 * Maps a class name to another name in this hashtable. If the hashtable contains another mapping from the same class name, the old mapping is replaced.  This method translates the given class names into the internal form used in the JVM before putting it in the hashtable. <p>If <code>oldname</code> is equivalent to <code>newname</code>, then this method does not perform anything; it does not record the mapping from <code>oldname</code> to <code>newname</code>.  See <code>fix</code> method.
 * @param oldname   the original class name
 * @param newname   the substituted class name.
 * @see #fix(String)
 */
public void put(String oldname,String newname){
  if (oldname == newname)   return;
  String oldname2=toJvmName(oldname);
  String s=(String)get(oldname2);
  if (s == null || !s.equals(oldname2))   super.put(oldname2,toJvmName(newname));
}
Program: 25750
Project: 25750
Buggy source:
/** 
 * @param isCons        true if this is a constructor.
 */
void copy(CtBehavior src,boolean isCons,ClassMap map) throws CannotCompileException {
  CtClass declaring=declaringClass;
  MethodInfo srcInfo=src.methodInfo;
  CtClass srcClass=src.getDeclaringClass();
  ConstPool cp=declaring.getClassFile2().getConstPool();
  if (map == null)   map=new ClassMap();
  map.put(srcClass.getName(),declaring.getName());
  try {
    boolean patch=false;
    CtClass srcSuper=srcClass.getSuperclass();
    String destSuperName=declaring.getSuperclass().getName();
    if (srcSuper != null) {
      String srcSuperName=srcSuper.getName();
      if (!srcSuperName.equals(destSuperName))       if (srcSuperName.equals(CtClass.javaLangObject))       patch=true;
 else       map.put(srcSuperName,destSuperName);
    }
    methodInfo=new MethodInfo(cp,srcInfo.getName(),srcInfo,map);
    if (isCons && patch)     methodInfo.setSuperclass(destSuperName);
  }
 catch (  NotFoundException e) {
    throw new CannotCompileException(e);
  }
catch (  BadBytecode e) {
    throw new CannotCompileException(e);
  }
}

Fixed version (ground truth):
/** 
 * @param isCons        true if this is a constructor.
 */
void copy(CtBehavior src,boolean isCons,ClassMap map) throws CannotCompileException {
  CtClass declaring=declaringClass;
  MethodInfo srcInfo=src.methodInfo;
  CtClass srcClass=src.getDeclaringClass();
  ConstPool cp=declaring.getClassFile2().getConstPool();
  if (map == null)   map=new ClassMap();
  map.add(srcClass.getName(),declaring.getName());
  try {
    boolean patch=false;
    CtClass srcSuper=srcClass.getSuperclass();
    CtClass destSuper=declaring.getSuperclass();
    String destSuperName=null;
    if (srcSuper != null && destSuper != null) {
      String srcSuperName=srcSuper.getName();
      destSuperName=destSuper.getName();
      if (!srcSuperName.equals(destSuperName))       if (srcSuperName.equals(CtClass.javaLangObject))       patch=true;
 else       map.add(srcSuperName,destSuperName);
    }
    methodInfo=new MethodInfo(cp,srcInfo.getName(),srcInfo,map);
    if (isCons && patch)     methodInfo.setSuperclass(destSuperName);
  }
 catch (  NotFoundException e) {
    throw new CannotCompileException(e);
  }
catch (  BadBytecode e) {
    throw new CannotCompileException(e);
  }
}
Program: 25752
Project: 25752
Buggy source:
/** 
 * Writes this annotation.
 * @param writer            the output.
 */
public void write(AnnotationsWriter writer) throws IOException {
  if (members == null) {
    writer.annotation(typeIndex,0);
    return;
  }
  writer.annotation(typeIndex,members.size());
  Iterator it=members.values().iterator();
  while (it.hasNext()) {
    Pair pair=(Pair)it.next();
    writer.memberValuePair(pair.name);
    pair.value.write(writer);
  }
}

Fixed version (ground truth):
/** 
 * Writes this annotation.
 * @param writer            the output.
 */
public void write(AnnotationsWriter writer) throws IOException {
  String typeName=pool.getUtf8Info(typeIndex);
  if (members == null) {
    writer.annotation(typeName,0);
    return;
  }
  writer.annotation(typeName,members.size());
  Iterator it=members.values().iterator();
  while (it.hasNext()) {
    Pair pair=(Pair)it.next();
    writer.memberValuePair(pair.name);
    pair.value.write(writer);
  }
}
Program: 25753
Project: 25753
Buggy source:
/** 
 * Writes the value.
 */
public void write(AnnotationsWriter writer) throws IOException {
  writer.classInfoIndex(valueIndex);
}

Fixed version (ground truth):
/** 
 * Writes the value.
 */
public void write(AnnotationsWriter writer) throws IOException {
  writer.classInfoIndex(cp.getUtf8Info(valueIndex));
}
Program: 25754
Project: 25754
Buggy source:
private Method lookupMethod(CtClass clazz,String methodName,int[] argTypes,int[] argDims,String[] argClassNames,boolean onlyExact) throws CompileError {
  Method maybe=null;
  List list=clazz.getClassFile2().getMethods();
  int n=list.size();
  for (int i=0; i < n; ++i) {
    MethodInfo minfo=(MethodInfo)list.get(i);
    if (minfo.getName().equals(methodName)) {
      int res=compareSignature(minfo.getDescriptor(),argTypes,argDims,argClassNames);
      if (res != NO) {
        Method r=new Method(clazz,minfo);
        if (res == YES)         return r;
 else         if (maybe == null)         maybe=r;
      }
    }
  }
  if (onlyExact)   maybe=null;
 else   onlyExact=maybe != null;
  try {
    CtClass pclazz=clazz.getSuperclass();
    if (pclazz != null) {
      Method r=lookupMethod(pclazz,methodName,argTypes,argDims,argClassNames,onlyExact);
      if (r != null)       return r;
    }
  }
 catch (  NotFoundException e) {
  }
  int mod=clazz.getModifiers();
  if (Modifier.isAbstract(mod) || Modifier.isInterface(mod))   try {
    CtClass[] ifs=clazz.getInterfaces();
    int size=ifs.length;
    for (int i=0; i < size; ++i) {
      Method r=lookupMethod(ifs[i],methodName,argTypes,argDims,argClassNames,onlyExact);
      if (r != null)       return r;
    }
  }
 catch (  NotFoundException e) {
  }
  return maybe;
}

Fixed version (ground truth):
private Method lookupMethod(CtClass clazz,String methodName,int[] argTypes,int[] argDims,String[] argClassNames,boolean onlyExact) throws CompileError {
  Method maybe=null;
  List list=clazz.getClassFile2().getMethods();
  int n=list.size();
  for (int i=0; i < n; ++i) {
    MethodInfo minfo=(MethodInfo)list.get(i);
    if (minfo.getName().equals(methodName)) {
      int res=compareSignature(minfo.getDescriptor(),argTypes,argDims,argClassNames);
      if (res != NO) {
        Method r=new Method(clazz,minfo,res);
        if (res == YES)         return r;
 else         if (maybe == null || maybe.notmatch > res)         maybe=r;
      }
    }
  }
  if (onlyExact)   maybe=null;
 else   onlyExact=maybe != null;
  try {
    CtClass pclazz=clazz.getSuperclass();
    if (pclazz != null) {
      Method r=lookupMethod(pclazz,methodName,argTypes,argDims,argClassNames,onlyExact);
      if (r != null)       return r;
    }
  }
 catch (  NotFoundException e) {
  }
  int mod=clazz.getModifiers();
  if (Modifier.isAbstract(mod) || Modifier.isInterface(mod))   try {
    CtClass[] ifs=clazz.getInterfaces();
    int size=ifs.length;
    for (int i=0; i < size; ++i) {
      Method r=lookupMethod(ifs[i],methodName,argTypes,argDims,argClassNames,onlyExact);
      if (r != null)       return r;
    }
  }
 catch (  NotFoundException e) {
  }
  return maybe;
}
Program: 25755
Project: 25755
Buggy source:
public Method(CtClass c,MethodInfo i){
  declaring=c;
  info=i;
}

Fixed version (ground truth):
public Method(CtClass c,MethodInfo i,int n){
  declaring=c;
  info=i;
  notmatch=n;
}
Program: 25757
Project: 25757
Buggy source:
/** 
 * Writes a class file represented by this <code>CtClass</code> object on a local disk. Once this method is called, further modifications are not possible any more.
 * @param directoryName     it must end without a directory separator.
 */
public void writeFile(String directoryName) throws NotFoundException, CannotCompileException, IOException {
  String classname=getName();
  String filename=directoryName + File.separatorChar + classname.replace('.',File.separatorChar)+ "String_Node_Str";
  int pos=filename.lastIndexOf(File.separatorChar);
  if (pos > 0) {
    String dir=filename.substring(0,pos);
    if (!dir.equals("String_Node_Str"))     new File(dir).mkdirs();
  }
  DataOutputStream out=new DataOutputStream(new BufferedOutputStream(new DelayedFileOutputStream(filename)));
  try {
    toBytecode(out);
  }
  finally {
    out.close();
  }
}

Fixed version (ground truth):
/** 
 * Writes a class file represented by this <code>CtClass</code> object on a local disk. Once this method is called, further modifications are not possible any more.
 * @param directoryName     it must end without a directory separator.
 */
public void writeFile(String directoryName) throws CannotCompileException, IOException {
  String classname=getName();
  String filename=directoryName + File.separatorChar + classname.replace('.',File.separatorChar)+ "String_Node_Str";
  int pos=filename.lastIndexOf(File.separatorChar);
  if (pos > 0) {
    String dir=filename.substring(0,pos);
    if (!dir.equals("String_Node_Str"))     new File(dir).mkdirs();
  }
  DataOutputStream out=new DataOutputStream(new BufferedOutputStream(new DelayedFileOutputStream(filename)));
  try {
    toBytecode(out);
  }
  finally {
    out.close();
  }
}
Program: 25758
Project: 25758
Buggy source:
static Object[][] toAnnotationType(ClassPool cp,ParameterAnnotationsAttribute a1,ParameterAnnotationsAttribute a2) throws ClassNotFoundException {
  int numParameters=0;
  if (a1 != null)   numParameters=a1.numParameters();
 else   if (a2 != null)   numParameters=a2.numParameters();
 else   return new Object[0][];
  Object[][] result=new Object[numParameters][];
  ClassLoader cl=ClassPool.getContextClassLoader();
  for (int i=0; i < numParameters; i++) {
    Annotation[] anno1, anno2;
    int size1, size2;
    if (a1 == null) {
      anno1=null;
      size1=0;
    }
 else {
      anno1=a1.getAnnotations()[i];
      size1=anno1.length;
    }
    if (a2 == null) {
      anno2=null;
      size2=0;
    }
 else {
      anno2=a2.getAnnotations()[i];
      size2=anno2.length;
    }
    result[i]=new Object[size1 + size2];
    for (int j=0; j < size1; ++j)     result[i][j]=anno1[j].toAnnotationType(cl,cp);
    for (int j=0; j < size2; ++j)     result[i][j + size1]=anno2[j].toAnnotationType(cl,cp);
  }
  return result;
}

Fixed version (ground truth):
static Object[][] toAnnotationType(ClassPool cp,ParameterAnnotationsAttribute a1,ParameterAnnotationsAttribute a2) throws ClassNotFoundException {
  int numParameters=0;
  if (a1 != null)   numParameters=a1.numParameters();
 else   if (a2 != null)   numParameters=a2.numParameters();
 else   return new Object[0][];
  Object[][] result=new Object[numParameters][];
  for (int i=0; i < numParameters; i++) {
    Annotation[] anno1, anno2;
    int size1, size2;
    if (a1 == null) {
      anno1=null;
      size1=0;
    }
 else {
      anno1=a1.getAnnotations()[i];
      size1=anno1.length;
    }
    if (a2 == null) {
      anno2=null;
      size2=0;
    }
 else {
      anno2=a2.getAnnotations()[i];
      size2=anno2.length;
    }
    result[i]=new Object[size1 + size2];
    for (int j=0; j < size1; ++j)     result[i][j]=toAnnoType(anno1[j],cp);
    for (int j=0; j < size2; ++j)     result[i][j + size1]=toAnnoType(anno2[j],cp);
  }
  return result;
}
Program: 25759
Project: 25759
Buggy source:
/** 
 * Is called when a method is invoked on a proxy instance associated with this handler.  This method must process that method invocation.
 * @param self          the proxy instance.
 * @param thisMethod    the overridden method declared in the superclass or interface.
 * @param proceed       the forwarder method for invoking the overridden method.  It is null if the overridden mehtod is abstract or declared in the interface.
 * @param args          an array of objects containing the values ofthe arguments passed in the method invocation on the proxy instance.  If a parameter type is a primitive type, the type of the array element is a wrapper class.
 * @return              the resulting value of the method invocation.
 * @throws Exception    if the method invocation fails.
 */
Object invoke(Object self,Method thisMethod,Method proceed,Object[] args) throws Exception ;

Fixed version (ground truth):
/** 
 * Is called when a method is invoked on a proxy instance associated with this handler.  This method must process that method invocation.
 * @param self          the proxy instance.
 * @param thisMethod    the overridden method declared in the superclass or interface.
 * @param proceed       the forwarder method for invoking the overridden method.  It is null if the overridden mehtod is abstract or declared in the interface.
 * @param args          an array of objects containing the values ofthe arguments passed in the method invocation on the proxy instance.  If a parameter type is a primitive type, the type of the array element is a wrapper class.
 * @return              the resulting value of the method invocation.
 * @throws Throwable    if the method invocation fails.
 */
Object invoke(Object self,Method thisMethod,Method proceed,Object[] args) throws Throwable ;
Program: 25760
Project: 25760
Buggy source:
public void atMethodCallCore(CtClass targetClass,String mname,ASTList args,boolean isStatic,boolean isSpecial,int aload0pos,MemberResolver.Method found) throws CompileError {
  int nargs=getMethodArgsLength(args);
  int[] types=new int[nargs];
  int[] dims=new int[nargs];
  String[] cnames=new String[nargs];
  if (!isStatic && found != null && found.isStatic()) {
    bytecode.addOpcode(POP);
    isStatic=true;
  }
  int stack=bytecode.getStackDepth();
  atMethodArgs(args,types,dims,cnames);
  int count=bytecode.getStackDepth() - stack + 1;
  if (found == null)   found=resolver.lookupMethod(targetClass,thisMethod,mname,types,dims,cnames,false);
  if (found == null) {
    String msg;
    if (mname.equals(MethodInfo.nameInit))     msg="String_Node_Str";
 else     msg="String_Node_Str" + mname + "String_Node_Str"+ targetClass.getName();
    throw new CompileError(msg);
  }
  atMethodCallCore2(targetClass,mname,isStatic,isSpecial,aload0pos,count,found);
}

Fixed version (ground truth):
public void atMethodCallCore(CtClass targetClass,String mname,ASTList args,boolean isStatic,boolean isSpecial,int aload0pos,MemberResolver.Method found) throws CompileError {
  int nargs=getMethodArgsLength(args);
  int[] types=new int[nargs];
  int[] dims=new int[nargs];
  String[] cnames=new String[nargs];
  if (!isStatic && found != null && found.isStatic()) {
    bytecode.addOpcode(POP);
    isStatic=true;
  }
  int stack=bytecode.getStackDepth();
  atMethodArgs(args,types,dims,cnames);
  int count=bytecode.getStackDepth() - stack + 1;
  if (found == null)   found=resolver.lookupMethod(targetClass,thisClass,thisMethod,mname,types,dims,cnames);
  if (found == null) {
    String msg;
    if (mname.equals(MethodInfo.nameInit))     msg="String_Node_Str";
 else     msg="String_Node_Str" + mname + "String_Node_Str"+ targetClass.getName();
    throw new CompileError(msg);
  }
  atMethodCallCore2(targetClass,mname,isStatic,isSpecial,aload0pos,count,found);
}
Program: 25761
Project: 25761
Buggy source:
public Method lookupMethod(CtClass clazz,MethodInfo current,String methodName,int[] argTypes,int[] argDims,String[] argClassNames,boolean onlyExact) throws CompileError {
  Method maybe=null;
  if (current != null)   if (current.getName().equals(methodName)) {
    int res=compareSignature(current.getDescriptor(),argTypes,argDims,argClassNames);
    Method r=new Method(clazz,current);
    if (res == YES)     return r;
 else     if (res == MAYBE && maybe == null)     maybe=r;
  }
  List list=clazz.getClassFile2().getMethods();
  int n=list.size();
  for (int i=0; i < n; ++i) {
    MethodInfo minfo=(MethodInfo)list.get(i);
    if (minfo.getName().equals(methodName)) {
      int res=compareSignature(minfo.getDescriptor(),argTypes,argDims,argClassNames);
      Method r=new Method(clazz,minfo);
      if (res == YES)       return r;
 else       if (res == MAYBE && maybe == null)       maybe=r;
    }
  }
  try {
    CtClass pclazz=clazz.getSuperclass();
    if (pclazz != null) {
      Method r=lookupMethod(pclazz,null,methodName,argTypes,argDims,argClassNames,(onlyExact || maybe != null));
      if (r != null)       return r;
    }
  }
 catch (  NotFoundException e) {
  }
  int mod=clazz.getModifiers();
  if (Modifier.isAbstract(mod) || Modifier.isInterface(mod))   try {
    CtClass[] ifs=clazz.getInterfaces();
    int size=ifs.length;
    for (int i=0; i < size; ++i) {
      Method r=lookupMethod(ifs[i],null,methodName,argTypes,argDims,argClassNames,(onlyExact || maybe != null));
      if (r != null)       return r;
    }
  }
 catch (  NotFoundException e) {
  }
  if (onlyExact)   return null;
 else   return maybe;
}

Fixed version (ground truth):
private Method lookupMethod(CtClass clazz,String methodName,int[] argTypes,int[] argDims,String[] argClassNames,boolean onlyExact) throws CompileError {
  Method maybe=null;
  List list=clazz.getClassFile2().getMethods();
  int n=list.size();
  for (int i=0; i < n; ++i) {
    MethodInfo minfo=(MethodInfo)list.get(i);
    if (minfo.getName().equals(methodName)) {
      int res=compareSignature(minfo.getDescriptor(),argTypes,argDims,argClassNames);
      if (res != NO) {
        Method r=new Method(clazz,minfo);
        if (res == YES)         return r;
 else         if (maybe == null)         maybe=r;
      }
    }
  }
  if (onlyExact)   maybe=null;
 else   onlyExact=maybe != null;
  try {
    CtClass pclazz=clazz.getSuperclass();
    if (pclazz != null) {
      Method r=lookupMethod(pclazz,methodName,argTypes,argDims,argClassNames,onlyExact);
      if (r != null)       return r;
    }
  }
 catch (  NotFoundException e) {
  }
  int mod=clazz.getModifiers();
  if (Modifier.isAbstract(mod) || Modifier.isInterface(mod))   try {
    CtClass[] ifs=clazz.getInterfaces();
    int size=ifs.length;
    for (int i=0; i < size; ++i) {
      Method r=lookupMethod(ifs[i],methodName,argTypes,argDims,argClassNames,onlyExact);
      if (r != null)       return r;
    }
  }
 catch (  NotFoundException e) {
  }
  return maybe;
}
Program: 25762
Project: 25762
Buggy source:
/** 
 * @return  a pair of the class declaring the invoked methodand the MethodInfo of that method.  Never null.
 */
public MemberResolver.Method atMethodCallCore(CtClass targetClass,String mname,ASTList args) throws CompileError {
  int nargs=getMethodArgsLength(args);
  int[] types=new int[nargs];
  int[] dims=new int[nargs];
  String[] cnames=new String[nargs];
  atMethodArgs(args,types,dims,cnames);
  MemberResolver.Method found=resolver.lookupMethod(targetClass,thisMethod,mname,types,dims,cnames,false);
  if (found == null) {
    String msg;
    if (mname.equals(MethodInfo.nameInit))     msg="String_Node_Str";
 else     msg="String_Node_Str" + mname + "String_Node_Str"+ targetClass.getName();
    throw new CompileError(msg);
  }
  String desc=found.info.getDescriptor();
  setReturnType(desc);
  return found;
}

Fixed version (ground truth):
/** 
 * @return  a pair of the class declaring the invoked methodand the MethodInfo of that method.  Never null.
 */
public MemberResolver.Method atMethodCallCore(CtClass targetClass,String mname,ASTList args) throws CompileError {
  int nargs=getMethodArgsLength(args);
  int[] types=new int[nargs];
  int[] dims=new int[nargs];
  String[] cnames=new String[nargs];
  atMethodArgs(args,types,dims,cnames);
  MemberResolver.Method found=resolver.lookupMethod(targetClass,thisClass,thisMethod,mname,types,dims,cnames);
  if (found == null) {
    String msg;
    if (mname.equals(MethodInfo.nameInit))     msg="String_Node_Str";
 else     msg="String_Node_Str" + mname + "String_Node_Str"+ targetClass.getName();
    throw new CompileError(msg);
  }
  String desc=found.info.getDescriptor();
  setReturnType(desc);
  return found;
}
Program: 25763
Project: 25763
Buggy source:
/** 
 * Requests the class loader to load a class.
 */
protected Class loadClass(String name,boolean resolve) throws ClassFormatError, ClassNotFoundException {
  Class c=findLoadedClass(name);
  if (c == null)   c=loadClassByDelegation(name);
  if (c == null)   c=findClass(name);
  if (c == null)   c=delegateToParent(name);
  if (resolve)   resolveClass(c);
  return c;
}

Fixed version (ground truth):
/** 
 * Requests the class loader to load a class.
 */
protected Class loadClass(String name,boolean resolve) throws ClassFormatError, ClassNotFoundException {
  name=name.intern();
synchronized (name) {
    Class c=findLoadedClass(name);
    if (c == null)     c=loadClassByDelegation(name);
    if (c == null)     c=findClass(name);
    if (c == null)     c=delegateToParent(name);
    if (resolve)     resolveClass(c);
    return c;
  }
}
Program: 25764
Project: 25764
Buggy source:
private int canReplace() throws CannotCompileException {
  int op=iterator.byteAt(newPos + 3);
  if (op == Opcode.DUP)   return 4;
 else   if (op == Opcode.DUP_X1 && iterator.byteAt(newPos + 4) == Opcode.SWAP)   return 5;
 else   throw new CannotCompileException("String_Node_Str");
}

Fixed version (ground truth):
private int canReplace() throws CannotCompileException {
  int op=iterator.byteAt(newPos + 3);
  if (op == Opcode.DUP)   return 4;
 else   if (op == Opcode.DUP_X1 && iterator.byteAt(newPos + 4) == Opcode.SWAP)   return 5;
 else   if (op == Opcode.INVOKESPECIAL)   return 3;
 else   throw new CannotCompileException("String_Node_Str");
}
Program: 25765
Project: 25765
Buggy source:
public Object invoke(Object proxy,Method method,Object[] args) throws Throwable {
  String name=method.getName();
  MemberValue mv=annotation.getMemberValue(name);
  if (mv == null)   return getDefault(name);
 else   return mv.getValue(classLoader,pool);
}

Fixed version (ground truth):
public Object invoke(Object proxy,Method method,Object[] args) throws Throwable {
  String name=method.getName();
  MemberValue mv=annotation.getMemberValue(name);
  if (mv == null)   return getDefault(name,method);
 else   return mv.getValue(classLoader,pool,method);
}
Program: 25766
Project: 25766
Buggy source:
private Object getDefault(String name) throws ClassNotFoundException, RuntimeException {
  String classname=annotation.getTypeName();
  if (pool != null)   try {
    CtClass cc=pool.get(classname);
    ClassFile cf=cc.getClassFile2();
    MethodInfo minfo=cf.getMethod(name);
    if (minfo != null) {
      AnnotationDefaultAttribute ainfo=(AnnotationDefaultAttribute)minfo.getAttribute(AnnotationDefaultAttribute.tag);
      if (ainfo != null) {
        MemberValue mv=ainfo.getDefaultValue();
        return mv.getValue(classLoader,pool);
      }
    }
  }
 catch (  NotFoundException e) {
    throw new RuntimeException("String_Node_Str" + classname);
  }
  throw new RuntimeException("String_Node_Str" + classname + "String_Node_Str"+ name+ "String_Node_Str");
}

Fixed version (ground truth):
private Object getDefault(String name,Method method) throws ClassNotFoundException, RuntimeException {
  String classname=annotation.getTypeName();
  if (pool != null)   try {
    CtClass cc=pool.get(classname);
    ClassFile cf=cc.getClassFile2();
    MethodInfo minfo=cf.getMethod(name);
    if (minfo != null) {
      AnnotationDefaultAttribute ainfo=(AnnotationDefaultAttribute)minfo.getAttribute(AnnotationDefaultAttribute.tag);
      if (ainfo != null) {
        MemberValue mv=ainfo.getDefaultValue();
        return mv.getValue(classLoader,pool,method);
      }
    }
  }
 catch (  NotFoundException e) {
    throw new RuntimeException("String_Node_Str" + classname);
  }
  throw new RuntimeException("String_Node_Str" + classname + "String_Node_Str"+ name+ "String_Node_Str");
}
Program: 25767
Project: 25767
Buggy source:
/** 
 * Returns the value.  If the value type is a primitive type, the returned value is boxed.
 */
abstract Object getValue(ClassLoader cl,ClassPool cp) throws ClassNotFoundException ;

Fixed version (ground truth):
/** 
 * Returns the value.  If the value type is a primitive type, the returned value is boxed.
 */
abstract Object getValue(ClassLoader cl,ClassPool cp,Method m) throws ClassNotFoundException ;
Program: 25768
Project: 25768
Buggy source:
private LocalVariableAttribute(ConstPool cp,byte[] i){
  super(cp,tag,i);
}

Fixed version (ground truth):
private LocalVariableAttribute(ConstPool cp,String name,byte[] i){
  super(cp,name,i);
}
Program: 25769
Project: 25769
Buggy source:
/** 
 * Makes a copy.
 * @param newCp     the constant pool table used by the new copy.
 * @param classnames        should be null.
 */
public AttributeInfo copy(ConstPool newCp,Map classnames){
  byte[] src=get();
  byte[] dest=new byte[src.length];
  ConstPool cp=getConstPool();
  LocalVariableAttribute attr=new LocalVariableAttribute(newCp,dest);
  int n=ByteArray.readU16bit(src,0);
  ByteArray.write16bit(n,dest,0);
  int j=2;
  for (int i=0; i < n; ++i) {
    int start=ByteArray.readU16bit(src,j);
    int len=ByteArray.readU16bit(src,j + 2);
    int name=ByteArray.readU16bit(src,j + 4);
    int type=ByteArray.readU16bit(src,j + 6);
    int index=ByteArray.readU16bit(src,j + 8);
    ByteArray.write16bit(start,dest,j);
    ByteArray.write16bit(len,dest,j + 2);
    if (name != 0)     name=cp.copy(name,newCp,null);
    ByteArray.write16bit(name,dest,j + 4);
    if (type != 0)     type=cp.copy(type,newCp,null);
    ByteArray.write16bit(type,dest,j + 6);
    ByteArray.write16bit(index,dest,j + 8);
    j+=10;
  }
  return attr;
}

Fixed version (ground truth):
/** 
 * Makes a copy.
 * @param newCp     the constant pool table used by the new copy.
 * @param classnames        should be null.
 */
public AttributeInfo copy(ConstPool newCp,Map classnames){
  byte[] src=get();
  byte[] dest=new byte[src.length];
  ConstPool cp=getConstPool();
  LocalVariableAttribute attr=new LocalVariableAttribute(newCp,getName(),dest);
  int n=ByteArray.readU16bit(src,0);
  ByteArray.write16bit(n,dest,0);
  int j=2;
  for (int i=0; i < n; ++i) {
    int start=ByteArray.readU16bit(src,j);
    int len=ByteArray.readU16bit(src,j + 2);
    int name=ByteArray.readU16bit(src,j + 4);
    int type=ByteArray.readU16bit(src,j + 6);
    int index=ByteArray.readU16bit(src,j + 8);
    ByteArray.write16bit(start,dest,j);
    ByteArray.write16bit(len,dest,j + 2);
    if (name != 0)     name=cp.copy(name,newCp,null);
    ByteArray.write16bit(name,dest,j + 4);
    if (type != 0)     type=cp.copy(type,newCp,null);
    ByteArray.write16bit(type,dest,j + 6);
    ByteArray.write16bit(index,dest,j + 8);
    j+=10;
  }
  return attr;
}