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;
 }