AnnotationDefaultAttr.java 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright (c) 2010 Per M.A. Bothner.
  2. // This is free software; for terms and warranty disclaimer see ./COPYING.
  3. package gnu.bytecode;
  4. import java.io.*;
  5. /** Represents a "AnnotationDefault" attribute. */
  6. public class AnnotationDefaultAttr extends Attribute
  7. {
  8. int dataLength;
  9. AnnotationEntry.Value value;
  10. public AnnotationDefaultAttr (String name, AnnotationEntry.Value value, AttrContainer container)
  11. {
  12. super(name);
  13. this.value = value;
  14. addToFrontOf(container);
  15. }
  16. public int getLength() { return dataLength; }
  17. public void print (ClassTypeWriter dst)
  18. {
  19. dst.print("Attribute \"");
  20. dst.print(getName());
  21. dst.print("\", length:");
  22. dst.println(getLength());
  23. dst.print(" Default: ");
  24. value.print(2, dst);
  25. }
  26. public void assignConstants (ClassType cl)
  27. {
  28. super.assignConstants(cl);
  29. dataLength += RuntimeAnnotationsAttr.assignConstants(value, cl.getConstants());
  30. }
  31. public void write (DataOutputStream dstr) throws java.io.IOException
  32. {
  33. RuntimeAnnotationsAttr.write(value, getConstants(), dstr);
  34. }
  35. }