/** * Constructs a new {@link FieldWriter}. * * @param cw the class writer to which this field must be added. * @param access the field's access flags (see {@link Opcodes}). * @param name the field's name. * @param desc the field's descriptor (see {@link Type}). * @param signature the field's signature. May be <tt>null</tt>. * @param value the field's constant value. May be <tt>null</tt>. */ FieldWriter( final ClassWriter cw, final int access, final String name, final String desc, final String signature, final Object value) { super(Opcodes.ASM4); if (cw.firstField == null) { cw.firstField = this; } else { cw.lastField.fv = this; } cw.lastField = this; this.cw = cw; this.access = access; this.name = cw.newUTF8(name); this.desc = cw.newUTF8(desc); if (ClassReader.SIGNATURES && signature != null) { this.signature = cw.newUTF8(signature); } if (value != null) { this.value = cw.newConstItem(value).index; } }
/** * Constructs a new {@link FieldWriter}. * * @param cw the class writer to which this field must be added. * @param access the field's access flags (see {@link Opcodes}). * @param name the field's name. * @param desc the field's descriptor (see {@link Type}). * @param signature the field's signature. May be <tt>null</tt>. * @param value the field's constant value. May be <tt>null</tt>. */ protected FieldWriter( final ClassWriter cw, final int access, final String name, final String desc, final String signature, final Object value) { if (cw.firstField == null) { cw.firstField = this; } else { cw.lastField.next = this; } cw.lastField = this; this.cw = cw; this.access = access; this.name = cw.newUTF8(name); this.desc = cw.newUTF8(desc); if (signature != null) { this.signature = cw.newUTF8(signature); } if (value != null) { this.value = cw.newConstItem(value).index; } }