/** * Returns <code>num_annotations</code>. */ public int numAnnotations() { return X_Byte.readU16bit(info, 0); }
/** * Appends a new entry. * * @param inner <code>inner_class_info_index</code> * @param outer <code>outer_class_info_index</code> * @param name <code>inner_name_index</code> * @param flags <code>inner_class_access_flags</code> */ public void append(int inner, int outer, int name, int flags) { byte[] data = get(); int len = data.length; byte[] newData = new byte[len + 8]; for (int i = 2; i < len; ++i) newData[i] = data[i]; int n = X_Byte.readU16bit(data, 0); X_Byte.write16bit(n + 1, newData, 0); X_Byte.write16bit(inner, newData, len); X_Byte.write16bit(outer, newData, len + 2); X_Byte.write16bit(name, newData, len + 4); X_Byte.write16bit(flags, newData, len + 6); set(newData); }
private void write16bit(int value) throws IOException { byte[] buf = new byte[2]; X_Byte.write16bit(value, buf, 0); output.write(buf); } }
/** * Sets <code>classes[nth].outer_class_info_index</code> to * the given index. */ public void setOuterClassIndex(int nth, int index) { X_Byte.write16bit(index, get(), nth * 8 + 4); }
final int annotation(int pos) throws Exception { int type = X_Byte.readU16bit(info, pos); int numPairs = X_Byte.readU16bit(info, pos + 2); return annotation(pos + 4, type, numPairs); }
ConstPool cp = getConstPool(); InnerClassesAttribute attr = new InnerClassesAttribute(newCp, dest); int n = X_Byte.readU16bit(src, 0); X_Byte.write16bit(n, dest, 0); int j = 2; for (int i = 0; i < n; ++i) { int innerClass = X_Byte.readU16bit(src, j); int outerClass = X_Byte.readU16bit(src, j + 2); int innerName = X_Byte.readU16bit(src, j + 4); int innerAccess = X_Byte.readU16bit(src, j + 6); X_Byte.write16bit(innerClass, dest, j); X_Byte.write16bit(outerClass, dest, j + 2); X_Byte.write16bit(innerName, dest, j + 4); X_Byte.write16bit(innerAccess, dest, j + 6); j += 8;
/** * Sets <code>classes[nth].inner_class_info_index</code> to * the given index. */ public void setInnerClassIndex(int nth, int index) { X_Byte.write16bit(index, get(), nth * 8 + 2); }
/** * Returns <code>constantvalue_index</code>. */ public int getConstantValue() { return X_Byte.readU16bit(get(), 0); }
/** * Sets <code>classes[nth].inner_name_index</code> to * the given index. */ public void setInnerNameIndex(int nth, int index) { X_Byte.write16bit(index, get(), nth * 8 + 6); }
/** * Returns <code>classes[nth].inner_class_info_index</code>. */ public int innerClassIndex(int nth) { return X_Byte.readU16bit(get(), nth * 8 + 2); }
/** * Constructs an empty InnerClasses attribute. * * @see #append(String, String, String, int) */ public InnerClassesAttribute(ConstPool cp) { super(cp, tag, new byte[2]); X_Byte.write16bit(0, get(), 0); }
/** * Returns <code>classes[nth].outer_class_info_index</code>. */ public int outerClassIndex(int nth) { return X_Byte.readU16bit(get(), nth * 8 + 4); }
/** * Sets <code>classes[nth].inner_class_access_flags</code> to * the given index. */ public void setAccessFlags(int nth, int flags) { X_Byte.write16bit(flags, get(), nth * 8 + 8); }
/** * Returns <code>classes[nth].inner_name_index</code>. */ public int innerNameIndex(int nth) { return X_Byte.readU16bit(get(), nth * 8 + 6); }
/** * Sets <code>signature_index</code> to the index of the given signature, * which is added to a constant pool. * * @param sig new signature. * @since 3.11 */ public void setSignature(String sig) { int index = getConstPool().addUtf8Info(sig); X_Byte.write16bit(index, info, 0); }
/** * Returns <code>classes[nth].inner_class_access_flags</code>. */ public int accessFlags(int nth) { return X_Byte.readU16bit(get(), nth * 8 + 8); }
final int annotationArray(int pos) throws Exception { int num = X_Byte.readU16bit(info, pos); return annotationArray(pos + 2, num); }
final int memberValuePair(int pos) throws Exception { int nameIndex = X_Byte.readU16bit(info, pos); return memberValuePair(pos + 2, nameIndex); }
/** * Returns <code>number_of_classes</code>. */ public int tableLength() { return X_Byte.readU16bit(get(), 0); }
final int memberValue(int pos) throws Exception { int tag = info[pos] & 0xff; if (tag == 'e') { int typeNameIndex = X_Byte.readU16bit(info, pos + 1); int constNameIndex = X_Byte.readU16bit(info, pos + 3); enumMemberValue(typeNameIndex, constNameIndex); return pos + 5; } else if (tag == 'c') { int index = X_Byte.readU16bit(info, pos + 1); classMemberValue(index); return pos + 3; } else if (tag == '@') return annotationMemberValue(pos + 1); else if (tag == '[') { int num = X_Byte.readU16bit(info, pos + 1); return arrayMemberValue(pos + 3, num); } else { // primitive types or String. int index = X_Byte.readU16bit(info, pos + 1); constValueMember(tag, index); return pos + 3; } }