236 }
237 }
238
239 int copyConstantPool(int constantPoolCount) throws UnsupportedEncodingException {
240 int sdeIndex = -1;
241 // copy const pool index zero not in class file
242 for (int i = 1; i < constantPoolCount; ++i) {
243 int tag = readU1();
244 writeU1(tag);
245 switch (tag) {
246 case 7: // Class
247 case 8: // String
248 copy(2);
249 break;
250 case 9: // Field
251 case 10: // Method
252 case 11: // InterfaceMethod
253 case 3: // Integer
254 case 4: // Float
255 case 12: // NameAndType
256 copy(4);
257 break;
258 case 5: // Long
259 case 6: // Double
260 copy(8);
261 break;
262 case 1: // Utf8
263 int len = readU2();
264 writeU2(len);
265 byte[] utf8 = readBytes(len);
266 String str = new String(utf8, "UTF-8");
267 if (verbose) {
268 System.out.println(i + " read class attr -- '" + str + "'");
269 }
270 if (str.equals(nameSDE)) {
271 sdeIndex = i;
272 }
273 writeBytes(utf8);
274 break;
275 default:
276 abort("unexpected tag: " + tag);
277 break;
278 }
279 }
280 return sdeIndex;
|
236 }
237 }
238
239 int copyConstantPool(int constantPoolCount) throws UnsupportedEncodingException {
240 int sdeIndex = -1;
241 // copy const pool index zero not in class file
242 for (int i = 1; i < constantPoolCount; ++i) {
243 int tag = readU1();
244 writeU1(tag);
245 switch (tag) {
246 case 7: // Class
247 case 8: // String
248 copy(2);
249 break;
250 case 9: // Field
251 case 10: // Method
252 case 11: // InterfaceMethod
253 case 3: // Integer
254 case 4: // Float
255 case 12: // NameAndType
256 case 18: // InvokeDynamic
257 copy(4);
258 break;
259 case 5: // Long
260 case 6: // Double
261 copy(8);
262 break;
263 case 15: // MethodHandle
264 copy(3);
265 break;
266 case 1: // Utf8
267 int len = readU2();
268 writeU2(len);
269 byte[] utf8 = readBytes(len);
270 String str = new String(utf8, "UTF-8");
271 if (verbose) {
272 System.out.println(i + " read class attr -- '" + str + "'");
273 }
274 if (str.equals(nameSDE)) {
275 sdeIndex = i;
276 }
277 writeBytes(utf8);
278 break;
279 default:
280 abort("unexpected tag: " + tag);
281 break;
282 }
283 }
284 return sdeIndex;
|