1 30 31 package oracle.toplink.libraries.asm.attrs; 32 33 import oracle.toplink.libraries.asm.Attribute; 34 import oracle.toplink.libraries.asm.ByteVector; 35 import oracle.toplink.libraries.asm.ClassReader; 36 import oracle.toplink.libraries.asm.ClassWriter; 37 import oracle.toplink.libraries.asm.Label; 38 39 40 85 86 public class EnclosingMethodAttribute extends Attribute { 87 88 public String owner; 89 public String name; 90 public String desc; 91 92 public EnclosingMethodAttribute () { 93 super("EnclosingMethod"); 94 } 95 96 public EnclosingMethodAttribute (String owner, String name, String desc) { 97 this(); 98 this.owner = owner; 99 this.name = name; 100 this.desc = desc; 101 } 102 103 protected Attribute read (ClassReader cr, int off, 104 int len, char[] buf, int codeOff, Label[] labels) { 105 String o = cr.readClass( off, buf); 107 int index = cr.getItem(cr.readUnsignedShort(off + 2)); 109 String n = null; 110 String d = null; 111 if( index!=0) { 112 n = cr.readUTF8(index, buf); 113 d = cr.readUTF8(index + 2, buf); 114 } 115 return new EnclosingMethodAttribute( o, n, d); 116 } 117 118 protected ByteVector write (ClassWriter cw, byte[] code, 119 int len, int maxStack, int maxLocals) { 120 return new ByteVector().putShort(cw.newClass(owner)) 121 .putShort( name==null || desc==null ? 0 : cw.newNameType(name, desc)); 122 } 123 124 public String toString () { 125 return new StringBuffer ("owner:").append( owner) 126 .append(" name:").append(name) 127 .append(" desc:").append(desc).toString(); 128 } 129 } 130 131 | Popular Tags |