public void addAttribute(String attributeName, ClassFormatOutput info) {

    if (attribute_info == null) attribute_info = new Attributes(1);

    CONSTANT_Utf8_info autf = addUtf8Entry(attributeName);

    int index = autf.getIndex();

    attribute_info.addEntry(new AttributeEntry(index, info));
  }
  /** Add a string entry */
  private int addString(String value) {
    CONSTANT_Utf8_info sutf = addUtf8Entry(value);
    int valueIndex = sutf.setAsString();
    if (valueIndex == 0) {
      // string is already being used as code
      valueIndex = addExtraUtf8(value).getIndex();
      sutf.setAlternative(valueIndex);
    }

    return addIndexReference(VMDescriptor.CONSTANT_String, valueIndex, 0);
  }
  private void doRenameString(int index, String newName) {
    ConstantPoolEntry cpe = getEntry(index);
    if (cpe.getTag() != VMDescriptor.CONSTANT_Utf8)
      throw new RuntimeException("unexpected type " + cpe);

    CONSTANT_Utf8_info newCpe = new CONSTANT_Utf8_info(newName);

    cptHashTable.remove(cpe.getKey());
    cptHashTable.put(newCpe.getKey(), newCpe);

    newCpe.index = index;

    cptEntries.set(index, newCpe);
  }
  /** @see ClassHolder#addMember */
  public ClassMember addMember(String simpleName, String descriptor, int modifier) {
    if (SanityManager.DEBUG) {
      if (descriptor.startsWith("(")) {
        if (method_info != null) {
          if (method_info.find(simpleName, descriptor) != null) {
            SanityManager.THROWASSERT("Method already exists " + simpleName + " " + descriptor);
          }
        }

      } else {
        if (field_info != null) {
          if (field_info.find(simpleName, descriptor) != null) {
            SanityManager.THROWASSERT("Field already exists " + simpleName + " " + descriptor);
          }
        }
      }
    }

    CONSTANT_Utf8_info utf = addUtf8Entry(simpleName);

    int nameIndex = utf.getIndex();
    int descriptorIndex = addUtf8Entry(descriptor).getIndex();

    ClassMember item = new ClassMember(this, modifier, nameIndex, descriptorIndex);
    MemberTable mt;
    if (descriptor.startsWith("(")) {
      mt = method_info;
      if (mt == null) mt = method_info = new MemberTable(0);

    } else {
      mt = field_info;
      if (mt == null) mt = field_info = new MemberTable(0);
    }

    mt.addEntry(item);
    return item;
  }
  /** Add a string entry */
  private int addCodeUtf8(String value) {
    CONSTANT_Utf8_info sutf = addUtf8Entry(value);
    int index = sutf.setAsCode();
    if (index == 0) {
      // code string is already being used as string
      CONSTANT_Utf8_info eutf = addExtraUtf8(value);
      eutf.setAsCode(); // ensure the replace will happen
      index = eutf.getIndex();
      sutf.setAlternative(index);
    }

    return index;
  }
 /**
  * Returns a String representation of this entry.
  *
  * @param constant_pool constant pool of ClassFile.
  * @return String representation of this entry.
  * @see cp_info#toString
  */
 public String toString(cp_info constant_pool[]) {
   CONSTANT_Utf8_info ci = (CONSTANT_Utf8_info) (constant_pool[name_index]);
   // CONSTANT_Utf8_info di = (CONSTANT_Utf8_info)(constant_pool[descriptor_index]);
   return ci.convert(); // + "/" + di.convert();
 }