private int getOrInsertString(int utf8Index) throws IOException {
   int stringIndex = constantPool.lookForString(utf8Index);
   if (stringIndex == -1) {
     stringIndex = constantPool.poolSize() + 1;
     StringConstant stringConstant = new StringConstant(utf8Index);
     constantPool.add(stringConstant);
     stringConstant.serializeToStream(constantStream);
   }
   return stringIndex;
 }
 private int getOrInsertMethodRef(int classIndex, int nameAndTypeIndex) throws IOException {
   int methodRef = constantPool.lookForRef(classIndex, nameAndTypeIndex);
   if (methodRef == -1) {
     methodRef = constantPool.poolSize() + 1;
     MethodRefConstant methodRefConstant = new MethodRefConstant(classIndex, nameAndTypeIndex);
     constantPool.add(methodRefConstant);
     methodRefConstant.serializeToStream(constantStream);
   }
   return methodRef;
 }
 private int getOrInsertNameAndType(int nameIndex, int typeIndex) throws IOException {
   int nameAndTypeIndex = constantPool.lookForNameAndTypeReference(nameIndex, typeIndex);
   if (nameAndTypeIndex == -1) {
     nameAndTypeIndex = constantPool.poolSize() + 1;
     NameAndTypeConstant nameAndType = new NameAndTypeConstant(nameIndex, typeIndex);
     constantPool.add(nameAndType);
     nameAndType.serializeToStream(constantStream);
   }
   return nameAndTypeIndex;
 }
 private int getOrInsertClass(int nameIndex) throws IOException {
   int classIndex = constantPool.lookForClass(nameIndex);
   if (classIndex == -1) {
     classIndex = constantPool.poolSize() + 1;
     ClassConstant classConstant = new ClassConstant(nameIndex);
     constantPool.add(classConstant);
     classConstant.serializeToStream(constantStream);
   }
   return classIndex;
 }
 private int getOrInsertUtf8(String string) throws IOException {
   int nameIndex = constantPool.lookForUtf8Reference(string);
   if (nameIndex == -1) {
     nameIndex = constantPool.poolSize() + 1;
     Utf8Constant name = new Utf8Constant(string);
     constantPool.add(name);
     name.serializeToStream(constantStream);
   }
   return nameIndex;
 }