1 15 16 package javassist.bytecode; 17 18 import java.io.DataInputStream ; 19 import java.util.Map ; 20 import java.io.IOException ; 21 22 25 public class ConstantAttribute extends AttributeInfo { 26 29 public static final String tag = "ConstantValue"; 30 31 ConstantAttribute(ConstPool cp, int n, DataInputStream in) 32 throws IOException 33 { 34 super(cp, n, in); 35 } 36 37 44 public ConstantAttribute(ConstPool cp, int index) { 45 super(cp, tag); 46 byte[] bvalue = new byte[2]; 47 bvalue[0] = (byte)(index >>> 8); 48 bvalue[1] = (byte)index; 49 set(bvalue); 50 } 51 52 55 public int getConstantValue() { 56 return ByteArray.readU16bit(get(), 0); 57 } 58 59 67 public AttributeInfo copy(ConstPool newCp, Map classnames) { 68 int index = getConstPool().copy(getConstantValue(), newCp, 69 classnames); 70 return new ConstantAttribute(newCp, index); 71 } 72 } 73 | Popular Tags |