コード例 #1
0
 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;
 }
コード例 #2
0
 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;
 }
コード例 #3
0
 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;
 }
コード例 #4
0
 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;
 }
コード例 #5
0
 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;
 }