Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2000, 2009 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2011 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
Lines 33-51
public class ConstantPool extends ClassFileStruct implements IConstantPool {
Link Here
|
33 |
* @see IConstantPool#decodeEntry(int) |
33 |
* @see IConstantPool#decodeEntry(int) |
34 |
*/ |
34 |
*/ |
35 |
public IConstantPoolEntry decodeEntry(int index) { |
35 |
public IConstantPoolEntry decodeEntry(int index) { |
36 |
ConstantPoolEntry constantPoolEntry = new ConstantPoolEntry(); |
36 |
ConstantPoolEntry constantPoolEntry = null; |
37 |
constantPoolEntry.reset(); |
|
|
38 |
int kind = getEntryKind(index); |
37 |
int kind = getEntryKind(index); |
39 |
constantPoolEntry.setKind(kind); |
|
|
40 |
switch(kind) { |
38 |
switch(kind) { |
41 |
case IConstantPoolConstant.CONSTANT_Class : |
39 |
case IConstantPoolConstant.CONSTANT_Class : |
|
|
40 |
constantPoolEntry = new ConstantPoolEntry(); |
41 |
constantPoolEntry.reset(); |
42 |
constantPoolEntry.setKind(kind); |
42 |
constantPoolEntry.setClassInfoNameIndex(u2At(this.classFileBytes, 1, this.constantPoolOffset[index])); |
43 |
constantPoolEntry.setClassInfoNameIndex(u2At(this.classFileBytes, 1, this.constantPoolOffset[index])); |
43 |
constantPoolEntry.setClassInfoName(getUtf8ValueAt(constantPoolEntry.getClassInfoNameIndex())); |
44 |
constantPoolEntry.setClassInfoName(getUtf8ValueAt(constantPoolEntry.getClassInfoNameIndex())); |
44 |
break; |
45 |
break; |
45 |
case IConstantPoolConstant.CONSTANT_Double : |
46 |
case IConstantPoolConstant.CONSTANT_Double : |
|
|
47 |
constantPoolEntry = new ConstantPoolEntry(); |
48 |
constantPoolEntry.reset(); |
49 |
constantPoolEntry.setKind(kind); |
46 |
constantPoolEntry.setDoubleValue(doubleAt(this.classFileBytes, 1, this.constantPoolOffset[index])); |
50 |
constantPoolEntry.setDoubleValue(doubleAt(this.classFileBytes, 1, this.constantPoolOffset[index])); |
47 |
break; |
51 |
break; |
48 |
case IConstantPoolConstant.CONSTANT_Fieldref : |
52 |
case IConstantPoolConstant.CONSTANT_Fieldref : |
|
|
53 |
constantPoolEntry = new ConstantPoolEntry(); |
54 |
constantPoolEntry.reset(); |
55 |
constantPoolEntry.setKind(kind); |
56 |
constantPoolEntry.reset(); |
57 |
constantPoolEntry.setKind(kind); |
49 |
constantPoolEntry.setClassIndex(u2At(this.classFileBytes, 1, this.constantPoolOffset[index])); |
58 |
constantPoolEntry.setClassIndex(u2At(this.classFileBytes, 1, this.constantPoolOffset[index])); |
50 |
int declaringClassIndex = u2At(this.classFileBytes, 1, this.constantPoolOffset[constantPoolEntry.getClassIndex()]); |
59 |
int declaringClassIndex = u2At(this.classFileBytes, 1, this.constantPoolOffset[constantPoolEntry.getClassIndex()]); |
51 |
constantPoolEntry.setClassName(getUtf8ValueAt(declaringClassIndex)); |
60 |
constantPoolEntry.setClassName(getUtf8ValueAt(declaringClassIndex)); |
Lines 57-62
public class ConstantPool extends ClassFileStruct implements IConstantPool {
Link Here
|
57 |
break; |
66 |
break; |
58 |
case IConstantPoolConstant.CONSTANT_Methodref : |
67 |
case IConstantPoolConstant.CONSTANT_Methodref : |
59 |
case IConstantPoolConstant.CONSTANT_InterfaceMethodref : |
68 |
case IConstantPoolConstant.CONSTANT_InterfaceMethodref : |
|
|
69 |
constantPoolEntry = new ConstantPoolEntry(); |
70 |
constantPoolEntry.reset(); |
71 |
constantPoolEntry.setKind(kind); |
72 |
constantPoolEntry.reset(); |
73 |
constantPoolEntry.setKind(kind); |
60 |
constantPoolEntry.setClassIndex(u2At(this.classFileBytes, 1, this.constantPoolOffset[index])); |
74 |
constantPoolEntry.setClassIndex(u2At(this.classFileBytes, 1, this.constantPoolOffset[index])); |
61 |
declaringClassIndex = u2At(this.classFileBytes, 1, this.constantPoolOffset[constantPoolEntry.getClassIndex()]); |
75 |
declaringClassIndex = u2At(this.classFileBytes, 1, this.constantPoolOffset[constantPoolEntry.getClassIndex()]); |
62 |
constantPoolEntry.setClassName(getUtf8ValueAt(declaringClassIndex)); |
76 |
constantPoolEntry.setClassName(getUtf8ValueAt(declaringClassIndex)); |
Lines 67-91
public class ConstantPool extends ClassFileStruct implements IConstantPool {
Link Here
|
67 |
constantPoolEntry.setMethodDescriptor(getUtf8ValueAt(methodDescriptorIndex)); |
81 |
constantPoolEntry.setMethodDescriptor(getUtf8ValueAt(methodDescriptorIndex)); |
68 |
break; |
82 |
break; |
69 |
case IConstantPoolConstant.CONSTANT_Float : |
83 |
case IConstantPoolConstant.CONSTANT_Float : |
|
|
84 |
constantPoolEntry = new ConstantPoolEntry(); |
85 |
constantPoolEntry.reset(); |
86 |
constantPoolEntry.setKind(kind); |
87 |
constantPoolEntry.reset(); |
88 |
constantPoolEntry.setKind(kind); |
70 |
constantPoolEntry.setFloatValue(floatAt(this.classFileBytes, 1, this.constantPoolOffset[index])); |
89 |
constantPoolEntry.setFloatValue(floatAt(this.classFileBytes, 1, this.constantPoolOffset[index])); |
71 |
break; |
90 |
break; |
72 |
case IConstantPoolConstant.CONSTANT_Integer : |
91 |
case IConstantPoolConstant.CONSTANT_Integer : |
|
|
92 |
constantPoolEntry = new ConstantPoolEntry(); |
93 |
constantPoolEntry.reset(); |
94 |
constantPoolEntry.setKind(kind); |
73 |
constantPoolEntry.setIntegerValue(i4At(this.classFileBytes, 1, this.constantPoolOffset[index])); |
95 |
constantPoolEntry.setIntegerValue(i4At(this.classFileBytes, 1, this.constantPoolOffset[index])); |
74 |
break; |
96 |
break; |
75 |
case IConstantPoolConstant.CONSTANT_Long : |
97 |
case IConstantPoolConstant.CONSTANT_Long : |
|
|
98 |
constantPoolEntry = new ConstantPoolEntry(); |
99 |
constantPoolEntry.reset(); |
100 |
constantPoolEntry.setKind(kind); |
76 |
constantPoolEntry.setLongValue(i8At(this.classFileBytes, 1, this.constantPoolOffset[index])); |
101 |
constantPoolEntry.setLongValue(i8At(this.classFileBytes, 1, this.constantPoolOffset[index])); |
77 |
break; |
102 |
break; |
78 |
case IConstantPoolConstant.CONSTANT_NameAndType : |
103 |
case IConstantPoolConstant.CONSTANT_NameAndType : |
|
|
104 |
constantPoolEntry = new ConstantPoolEntry(); |
105 |
constantPoolEntry.reset(); |
106 |
constantPoolEntry.setKind(kind); |
79 |
constantPoolEntry.setNameAndTypeNameIndex(u2At(this.classFileBytes, 1, this.constantPoolOffset[index])); |
107 |
constantPoolEntry.setNameAndTypeNameIndex(u2At(this.classFileBytes, 1, this.constantPoolOffset[index])); |
80 |
constantPoolEntry.setNameAndTypeDescriptorIndex(u2At(this.classFileBytes, 3, this.constantPoolOffset[index])); |
108 |
constantPoolEntry.setNameAndTypeDescriptorIndex(u2At(this.classFileBytes, 3, this.constantPoolOffset[index])); |
81 |
break; |
109 |
break; |
82 |
case IConstantPoolConstant.CONSTANT_String : |
110 |
case IConstantPoolConstant.CONSTANT_String : |
|
|
111 |
constantPoolEntry = new ConstantPoolEntry(); |
112 |
constantPoolEntry.reset(); |
113 |
constantPoolEntry.setKind(kind); |
83 |
constantPoolEntry.setStringIndex(u2At(this.classFileBytes, 1, this.constantPoolOffset[index])); |
114 |
constantPoolEntry.setStringIndex(u2At(this.classFileBytes, 1, this.constantPoolOffset[index])); |
84 |
constantPoolEntry.setStringValue(getUtf8ValueAt(constantPoolEntry.getStringIndex())); |
115 |
constantPoolEntry.setStringValue(getUtf8ValueAt(constantPoolEntry.getStringIndex())); |
85 |
break; |
116 |
break; |
86 |
case IConstantPoolConstant.CONSTANT_Utf8 : |
117 |
case IConstantPoolConstant.CONSTANT_Utf8 : |
|
|
118 |
constantPoolEntry = new ConstantPoolEntry(); |
119 |
constantPoolEntry.reset(); |
120 |
constantPoolEntry.setKind(kind); |
87 |
constantPoolEntry.setUtf8Length(u2At(this.classFileBytes, 1, this.constantPoolOffset[index])); |
121 |
constantPoolEntry.setUtf8Length(u2At(this.classFileBytes, 1, this.constantPoolOffset[index])); |
88 |
constantPoolEntry.setUtf8Value(getUtf8ValueAt(index)); |
122 |
constantPoolEntry.setUtf8Value(getUtf8ValueAt(index)); |
|
|
123 |
break; |
124 |
case IConstantPoolConstant.CONSTANT_MethodHandle : |
125 |
ConstantPoolEntry2 constantPoolEntry2 = new ConstantPoolEntry2(); |
126 |
constantPoolEntry2.reset(); |
127 |
constantPoolEntry2.setKind(kind); |
128 |
constantPoolEntry2.setReferenceKind(u1At(this.classFileBytes, 1, this.constantPoolOffset[index])); |
129 |
constantPoolEntry2.setReferenceIndex(u2At(this.classFileBytes, 2, this.constantPoolOffset[index])); |
130 |
constantPoolEntry = constantPoolEntry2; |
131 |
break; |
132 |
case IConstantPoolConstant.CONSTANT_MethodType : |
133 |
constantPoolEntry2 = new ConstantPoolEntry2(); |
134 |
constantPoolEntry2.reset(); |
135 |
constantPoolEntry2.setKind(kind); |
136 |
methodDescriptorIndex = u2At(this.classFileBytes, 1, this.constantPoolOffset[index]); |
137 |
constantPoolEntry2.setDescriptorIndex(methodDescriptorIndex); |
138 |
constantPoolEntry2.setMethodDescriptor(getUtf8ValueAt(methodDescriptorIndex)); |
139 |
constantPoolEntry = constantPoolEntry2; |
140 |
break; |
141 |
case IConstantPoolConstant.CONSTANT_InvokeDynamic : |
142 |
constantPoolEntry2 = new ConstantPoolEntry2(); |
143 |
constantPoolEntry2.reset(); |
144 |
constantPoolEntry2.setKind(kind); |
145 |
constantPoolEntry2.setBootstrapMethodAttributeIndex(u2At(this.classFileBytes, 1, this.constantPoolOffset[index])); |
146 |
int nameAndTypeIndex = u2At(this.classFileBytes, 3, this.constantPoolOffset[index]); |
147 |
constantPoolEntry2.setNameAndTypeIndex(nameAndTypeIndex); |
148 |
methodNameIndex = u2At(this.classFileBytes, 1, this.constantPoolOffset[nameAndTypeIndex]); |
149 |
methodDescriptorIndex = u2At(this.classFileBytes, 3, this.constantPoolOffset[nameAndTypeIndex]); |
150 |
constantPoolEntry2.setMethodName(getUtf8ValueAt(methodNameIndex)); |
151 |
constantPoolEntry2.setMethodDescriptor(getUtf8ValueAt(methodDescriptorIndex)); |
152 |
constantPoolEntry = constantPoolEntry2; |
153 |
break; |
89 |
} |
154 |
} |
90 |
return constantPoolEntry; |
155 |
return constantPoolEntry; |
91 |
} |
156 |
} |