Interface ClassFileWriter.AttributeWriter

Enclosing class:
ClassFileWriter

public static interface ClassFileWriter.AttributeWriter
This writes attributes.

For example, the following object writes a synthetic attribute:

ConstPoolWriter cpw = ...;
final int tag = cpw.addUtf8Info("Synthetic");
AttributeWriter aw = new AttributeWriter() {
    public int size() {
        return 1;
    }
    public void write(DataOutputStream out) throws java.io.IOException {
        out.writeShort(tag);
        out.writeInt(0);
    }
};
Since:
3.13
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the number of attributes that this writer will write.
    void
    Writes all the contents of the attributes.
  • Method Details

    • size

      int size()
      Returns the number of attributes that this writer will write.
    • write

      void write(DataOutputStream out) throws IOException
      Writes all the contents of the attributes. The binary representation of the contents is an array of attribute_info.
      Throws:
      IOException