1 package com.sun.org.apache.bcel.internal.generic; 2 3 56 import com.sun.org.apache.bcel.internal.classfile.*; 57 58 65 public abstract class FieldOrMethod extends CPInstruction implements LoadClass { 66 70 FieldOrMethod() {} 71 72 75 protected FieldOrMethod(short opcode, int index) { 76 super(opcode, index); 77 } 78 79 81 public String getSignature(ConstantPoolGen cpg) { 82 ConstantPool cp = cpg.getConstantPool(); 83 ConstantCP cmr = (ConstantCP)cp.getConstant(index); 84 ConstantNameAndType cnat = (ConstantNameAndType)cp.getConstant(cmr.getNameAndTypeIndex()); 85 86 return ((ConstantUtf8)cp.getConstant(cnat.getSignatureIndex())).getBytes(); 87 } 88 89 91 public String getName(ConstantPoolGen cpg) { 92 ConstantPool cp = cpg.getConstantPool(); 93 ConstantCP cmr = (ConstantCP)cp.getConstant(index); 94 ConstantNameAndType cnat = (ConstantNameAndType)cp.getConstant(cmr.getNameAndTypeIndex()); 95 return ((ConstantUtf8)cp.getConstant(cnat.getNameIndex())).getBytes(); 96 } 97 98 100 public String getClassName(ConstantPoolGen cpg) { 101 ConstantPool cp = cpg.getConstantPool(); 102 ConstantCP cmr = (ConstantCP)cp.getConstant(index); 103 return cp.getConstantString(cmr.getClassIndex(), com.sun.org.apache.bcel.internal.Constants.CONSTANT_Class).replace('/', '.'); 104 } 105 106 108 public ObjectType getClassType(ConstantPoolGen cpg) { 109 return new ObjectType(getClassName(cpg)); 110 } 111 112 114 public ObjectType getLoadClassType(ConstantPoolGen cpg) { 115 return getClassType(cpg); 116 } 117 } 118 | Popular Tags |