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