1 package serp.bytecode; 2 3 import java.io.*; 4 5 import serp.bytecode.visitor.*; 6 7 /*** 8 * An unrecognized attribute; class files are allowed to contain 9 * attributes that are not recognized, and the JVM must ignore them. 10 * 11 * @author Abe White 12 */ 13 public class UnknownAttribute extends Attribute { 14 private byte[] _value = new byte[0]; 15 16 UnknownAttribute(int nameIndex, Attributes owner) { 17 super(nameIndex, owner); 18 } 19 20 int getLength() { 21 return _value.length; 22 } 23 24 /*** 25 * The value is of unknown content, so it is stored as a byte array. 26 */ 27 public byte[] getValue() { 28 return _value; 29 } 30 31 /*** 32 * The value is of unknown content, so it is stored as a byte array. 33 */ 34 public void setValue(byte[] value) { 35 if (value == null) 36 value = new byte[0]; 37 _value = value; 38 } 39 40 public void acceptVisit(BCVisitor visit) { 41 visit.enterUnknownAttribute(this); 42 visit.exitUnknownAttribute(this); 43 } 44 45 void read(Attribute other) { 46 setValue(((UnknownAttribute) other).getValue()); 47 } 48 49 void read(DataInput in, int length) throws IOException { 50 _value = new byte[length]; 51 in.readFully(_value); 52 } 53 54 void write(DataOutput out, int length) throws IOException { 55 out.write(_value); 56 } 57 }