1 | public class InterfaceMethodRefCPInfo extends ConstantPoolEntry {↵ | | 1 | public class MethodRefCPInfo extends ConstantPoolEntry {↵
|
2 | /** the class name of the class defining the interface method */↵ | | 2 | /** the name of the class defining this method */↵
|
3 | private String interfaceMethodClassName;↵ | | 3 | private String methodClassName;↵
|
4 | /** the name of the interface nmethod */↵ | | 4 | /** the name of the method */↵
|
5 | private String interfaceMethodName;↵ | | 5 | private String methodName;↵
|
6 | /** the method signature of the interface method */↵ | | 6 | /** the method's type descriptor */↵
|
7 | private String interfaceMethodType;↵ | | 7 | private String methodType;↵
|
8 | /**↵ | | 8 | /**↵
|
9 | * the index into the constant pool of the class entry for the interface↵ | | 9 | The index into the constant pool which defines the class ↵
|
10 | * class↵ | | |
|
11 | */↵ | | 10 | of this method. */↵
|
12 | private int classIndex;↵ | | 11 | private int classIndex;↵
|
13 | /**↵ | | 12 | /**↵
|
14 | * the index into the constant pool of the name and type entry↵ | | 13 | * the index into the constant pool which defined the name and type↵
|
15 | * describing the method↵ | | 14 | * signature of the method↵
|
16 | */↵ | | 15 | */↵
|
17 | private int nameAndTypeIndex;↵ | | 16 | private int nameAndTypeIndex;↵
|
|
18 | /** Constructor. */↵ | | 17 | /** Constructor. */↵
|
19 | public InterfaceMethodRefCPInfo() {↵ | | 18 | public MethodRefCPInfo() {↵
|
20 | super(CONSTANT_INTERFACEMETHODREF, 1);↵ | | 19 | super(CONSTANT_METHODREF, 1);↵
|
21 | }↵ | | 20 | }↵
|
|
22 | /**↵ | | 21 | /**↵
|
23 | * read a constant pool entry from a class stream.↵ | | 22 | * read a constant pool entry from a class stream.↵
|
24 | *↵ | | 23 | *↵
|
25 | * @param cpStream the DataInputStream which contains the constant pool↵ | | 24 | * @param cpStream the DataInputStream which contains the constant pool↵
|
26 | * entry to be read.↵ | | 25 | * entry to be read.↵
|
27 | * @exception IOException if there is a problem reading the entry from↵ | | 26 | * @exception IOException if there is a problem reading the entry from↵
|
28 | * the stream.↵ | | 27 | * the stream.↵
|
29 | */↵ | | 28 | */↵
|
30 | public void read(DataInputStream cpStream) throws IOException {↵ | | 29 | public void read(DataInputStream cpStream) throws IOException {↵
|
31 | classIndex = cpStream.readUnsignedShort();↵ | | 30 | classIndex = cpStream.readUnsignedShort();↵
|
32 | nameAndTypeIndex = cpStream.readUnsignedShort();↵ | | 31 | nameAndTypeIndex = cpStream.readUnsignedShort();↵
|
33 | }↵ | | 32 | }↵
|
|
| | | 33 | /**↵
|
| | | 34 | * Print a readable version of the constant pool entry.↵
|
| | | 35 | *↵
|
| | | 36 | * @return the string representation of this constant pool entry.↵
|
| | | 37 | */↵
|
| | | 38 | public String toString() {↵
|
| | | 39 | String value;↵
|
|
| | | 40 | if (isResolved()) {↵
|
| | | 41 | value = "Method : Class = " + methodClassName + ", name = "↵
|
| | | 42 | + methodName + ", type = " + methodType;↵
|
| | | 43 | } else {↵
|
| | | 44 | value = "Method : Class index = " + classIndex↵
|
| | | 45 | + ", name and type index = " + nameAndTypeIndex;↵
|
| | | 46 | }↵
|
|
| | | 47 | return value;↵
|
| | | 48 | }↵
|
|
34 | /**↵ | | 49 | /**↵
|
35 | * Resolve this constant pool entry with respect to its dependents in↵ | | 50 | * Resolve this constant pool entry with respect to its dependents in↵
|
36 | * the constant pool.↵ | | 51 | * the constant pool.↵
|
37 | *↵ | | 52 | *↵
|
38 | * @param constantPool the constant pool of which this entry is a member↵ | | 53 | * @param constantPool the constant pool of which this entry is a member↵
|
39 | * and against which this entry is to be resolved.↵ | | 54 | * and against which this entry is to be resolved.↵
|
40 | */↵ | | 55 | */↵
|
41 | public void resolve(ConstantPool constantPool) {↵ | | 56 | public void resolve(ConstantPool constantPool) {↵
|
42 | ClassCPInfo interfaceMethodClass↵ | | 57 | ClassCPInfo methodClass↵
|
43 | = (ClassCPInfo) constantPool.getEntry(classIndex);↵ | | 58 | = (ClassCPInfo) constantPool.getEntry(classIndex);↵
|
|
44 | interfaceMethodClass.resolve(constantPool);↵ | | 59 | methodClass.resolve(constantPool);↵
|
|
45 | interfaceMethodClassName = interfaceMethodClass.getClassName();↵ | | 60 | methodClassName = methodClass.getClassName();↵
|
|
46 | NameAndTypeCPInfo nt↵ | | 61 | NameAndTypeCPInfo nt↵
|
47 | = (NameAndTypeCPInfo) constantPool.getEntry(nameAndTypeIndex);↵ | | 62 | = (NameAndTypeCPInfo) constantPool.getEntry(nameAndTypeIndex);↵
|
|
48 | nt.resolve(constantPool);↵ | | 63 | nt.resolve(constantPool);↵
|
|
49 | interfaceMethodName = nt.getName();↵ | | 64 | methodName = nt.getName();↵
|
50 | interfaceMethodType = nt.getType();↵ | | 65 | methodType = nt.getType();↵
|
|
51 | super.resolve(constantPool);↵ | | 66 | super.resolve(constantPool);↵
|
52 | }↵ | | 67 | }↵
|
|
53 | /**↵ | | |
|
54 | * Print a readable version of the constant pool entry.↵ | | |
|
55 | *↵ | | |
|
56 | * @return the string representation of this constant pool entry.↵ | | |
|
57 | */↵ | | |
|
58 | public String toString() {↵ | | |
|
59 | String value;↵ | | |
|
|
60 | if (isResolved()) {↵ | | |
|
61 | value = "InterfaceMethod : Class = " + interfaceMethodClassName↵ | | |
|
62 | + ", name = " + interfaceMethodName + ", type = "↵ | | |
|
63 | + interfaceMethodType;↵ | | |
|
64 | } else {↵ | | |
|
65 | value = "InterfaceMethod : Class index = " + classIndex↵ | | |
|
66 | + ", name and type index = " + nameAndTypeIndex;↵ | | |
|
67 | }↵ | | |
|
|
68 | return value;↵ | | |
|
69 | }↵ | | |
|
|
70 | /**↵ | | 68 | /**↵
|
71 | * Gets the name of the class defining the interface method↵ | | 69 | * Get the name of the class defining the method↵
|
72 | *↵ | | 70 | *↵
|
73 | * @return the name of the class defining the interface method↵ | | 71 | * @return the name of the class defining this method↵
|
74 | */↵ | | 72 | */↵
|
75 | public String getInterfaceMethodClassName() {↵ | | 73 | public String getMethodClassName() {↵
|
76 | return interfaceMethodClassName;↵ | | 74 | return methodClassName;↵
|
77 | }↵ | | 75 | }↵
|
|
78 | /**↵ | | 76 | /**↵
|
79 | * Get the name of the interface method↵ | | 77 | * Get the name of the method.↵
|
80 | *↵ | | 78 | *↵
|
81 | * @return the name of the interface method↵ | | 79 | * @return the name of the method.↵
|
82 | */↵ | | 80 | */↵
|
83 | public String getInterfaceMethodName() {↵ | | 81 | public String getMethodName() {↵
|
84 | return interfaceMethodName;↵ | | 82 | return methodName;↵
|
85 | }↵ | | 83 | }↵
|
|
86 | /**↵ | | 84 | /**↵
|
87 | * Gets the type of the interface method↵ | | 85 | * Get the type signature of the method.↵
|
88 | *↵ | | 86 | *↵
|
89 | * @return the interface method's type signature↵ | | 87 | * @return the type signature of the method.↵
|
90 | */↵ | | 88 | */↵
|
91 | public String getInterfaceMethodType() {↵ | | 89 | public String getMethodType() {↵
|
92 | return interfaceMethodType;↵ | | 90 | return methodType;↵
|
93 | | | 91 |
|