1 15 16 package javassist.bytecode; 17 18 import java.io.DataInputStream ; 19 import java.io.IOException ; 20 import java.util.Map ; 21 22 25 public class EnclosingMethodAttribute extends AttributeInfo { 26 29 public static final String tag = "EnclosingMethod"; 30 31 EnclosingMethodAttribute(ConstPool cp, int n, DataInputStream in) 32 throws IOException 33 { 34 super(cp, n, in); 35 } 36 37 45 public EnclosingMethodAttribute(ConstPool cp, String className, 46 String methodName, String methodDesc) { 47 super(cp, tag); 48 int ci = cp.addClassInfo(className); 49 int ni = cp.addNameAndTypeInfo(methodName, methodDesc); 50 byte[] bvalue = new byte[4]; 51 bvalue[0] = (byte)(ci >>> 8); 52 bvalue[1] = (byte)ci; 53 bvalue[2] = (byte)(ni >>> 8); 54 bvalue[3] = (byte)ni; 55 set(bvalue); 56 } 57 58 61 public int classIndex() { 62 return ByteArray.readU16bit(get(), 0); 63 } 64 65 68 public int methodIndex() { 69 return ByteArray.readU16bit(get(), 2); 70 } 71 72 75 public String className() { 76 return getConstPool().getClassInfo(classIndex()); 77 } 78 79 82 public String methodName() { 83 ConstPool cp = getConstPool(); 84 int mi = methodIndex(); 85 int ni = cp.getNameAndTypeName(mi); 86 return cp.getUtf8Info(ni); 87 } 88 89 92 public String methodDescriptor() { 93 ConstPool cp = getConstPool(); 94 int mi = methodIndex(); 95 int ti = cp.getNameAndTypeDescriptor(mi); 96 return cp.getUtf8Info(ti); 97 } 98 99 107 public AttributeInfo copy(ConstPool newCp, Map classnames) { 108 return new EnclosingMethodAttribute(newCp, className(), 109 methodName(), methodDescriptor()); 110 } 111 } 112 | Popular Tags |