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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
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) { innerClass = cp.copy(innerClass, newCp, classnames); 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;