1 29 30 package com.caucho.bytecode; 31 32 import com.caucho.log.Log; 33 34 import java.io.IOException ; 35 import java.util.logging.Logger ; 36 37 40 public class MethodRefConstant extends ConstantPoolEntry { 41 static private final Logger log = Log.open(MethodRefConstant.class); 42 43 private int _classIndex; 44 private int _nameAndTypeIndex; 45 46 49 MethodRefConstant(ConstantPool pool, int index, 50 int classIndex, int nameAndTypeIndex) 51 { 52 super(pool, index); 53 54 _classIndex = classIndex; 55 _nameAndTypeIndex = nameAndTypeIndex; 56 } 57 58 61 public int getClassIndex() 62 { 63 return _classIndex; 64 } 65 66 69 public void setClassIndex(int index) 70 { 71 _classIndex = index; 72 } 73 74 77 public String getClassName() 78 { 79 return getConstantPool().getClass(_classIndex).getName(); 80 } 81 82 85 public String getName() 86 { 87 return getConstantPool().getNameAndType(_nameAndTypeIndex).getName(); 88 } 89 90 93 public String getType() 94 { 95 return getConstantPool().getNameAndType(_nameAndTypeIndex).getType(); 96 } 97 98 101 public void setNameAndType(String name, String type) 102 { 103 _nameAndTypeIndex = getConstantPool().addNameAndType(name, type).getIndex(); 104 } 105 106 109 void write(ByteCodeWriter out) 110 throws IOException 111 { 112 out.write(ConstantPool.CP_METHOD_REF); 113 out.writeShort(_classIndex); 114 out.writeShort(_nameAndTypeIndex); 115 } 116 117 120 public int export(ConstantPool target) 121 { 122 return target.addMethodRef(getClassName(), getName(), getType()).getIndex(); 123 } 124 125 public String toString() 126 { 127 return "MethodRefConstant[" + getClassName() + "." + getName() + "(" + getType() + ")]"; 128 } 129 } 130 | Popular Tags |