72
* Finds or creates a FieldrefCpInfo constant pool entry for the given
73
* class and field, in the given class file.
74
* @return the constant pool index of the FieldrefCpInfo.
76
public int addFieldrefCpInfo(ProgramClassFile programClassFile,
77
ClassFile referencedClassFile,
78
MemberInfo referencedMemberInfo)
80
return addFieldrefCpInfo(programClassFile,
81
referencedClassFile.getName(),
82
referencedMemberInfo.getName(referencedClassFile),
83
referencedMemberInfo.getDescriptor(referencedClassFile),
85
referencedMemberInfo);
69
90
* Finds or creates a FieldrefCpInfo constant pool entry with the given
70
91
* class name, field name, and descriptor, in the given class file.
71
92
* @return the constant pool index of the FieldrefCpInfo.
179
* Finds or creates a MethodrefCpInfo constant pool entry with the given
180
* class name, method name, and descriptor, in the given class file.
181
* @return the constant pool index of the MethodrefCpInfo.
183
public int addMethodrefCpInfo(ProgramClassFile programClassFile,
187
ClassFile referencedClassFile,
188
MemberInfo referencedMemberInfo,
189
ClassFile[] referencedClassFiles)
191
return addMethodrefCpInfo(programClassFile,
193
addNameAndTypeCpInfo(programClassFile,
196
referencedClassFiles),
198
referencedMemberInfo);
203
* Finds or creates a MethodrefCpInfo constant pool entry with the given
204
* class name, method name, and descriptor, in the given class file.
205
* @return the constant pool index of the MethodrefCpInfo.
207
public int addMethodrefCpInfo(ProgramClassFile programClassFile,
209
int nameAndTypeIndex,
210
ClassFile referencedClassFile,
211
MemberInfo referencedMemberInfo)
213
return addMethodrefCpInfo(programClassFile,
214
addClassCpInfo(programClassFile,
216
referencedClassFile),
219
referencedMemberInfo);
224
* Finds or creates a MethodrefCpInfo constant pool entry with the given
225
* class constant pool entry index, method name, and descriptor, in the
227
* @return the constant pool index of the MethodrefCpInfo.
229
public int addMethodrefCpInfo(ProgramClassFile programClassFile,
233
ClassFile referencedClassFile,
234
MemberInfo referencedMemberInfo,
235
ClassFile[] referencedClassFiles)
237
return addMethodrefCpInfo(programClassFile,
239
addNameAndTypeCpInfo(programClassFile,
242
referencedClassFiles),
244
referencedMemberInfo);
249
* Finds or creates a MethodrefCpInfo constant pool entry with the given
250
* class constant pool entry index and name and type constant pool entry index
251
* the given class file.
252
* @return the constant pool index of the MethodrefCpInfo.
254
public int addMethodrefCpInfo(ProgramClassFile programClassFile,
256
int nameAndTypeIndex,
257
ClassFile referencedClassFile,
258
MemberInfo referencedMemberInfo)
260
CpInfo[] constantPool = programClassFile.constantPool;
261
int constantPoolCount = programClassFile.u2constantPoolCount;
263
// Check if the entry already exists.
264
for (int index = 1; index < constantPoolCount; index++)
266
CpInfo cpInfo = constantPool[index];
268
if (cpInfo != null &&
269
cpInfo.getTag() == ClassConstants.CONSTANT_Methodref)
271
MethodrefCpInfo methodrefCpInfo = (MethodrefCpInfo)cpInfo;
272
if (methodrefCpInfo.u2classIndex == classIndex &&
273
methodrefCpInfo.u2nameAndTypeIndex == nameAndTypeIndex)
280
return addCpInfo(programClassFile,
281
new MethodrefCpInfo(classIndex,
284
referencedMemberInfo));
289
196
* Finds or creates a InterfaceMethodrefCpInfo constant pool entry with the
290
197
* given class name, method name, and descriptor, in the given class file.
291
198
* @return the constant pool index of the InterfaceMethodrefCpInfo.
239
* Finds or creates a InterfaceMethodrefCpInfo constant pool entry for the
240
* given class and method, in the given class file.
241
* @return the constant pool index of the InterfaceMethodrefCpInfo.
243
public int addInterfaceMethodrefCpInfo(ProgramClassFile programClassFile,
244
ClassFile referencedClassFile,
245
MemberInfo referencedMemberInfo)
247
return addInterfaceMethodrefCpInfo(programClassFile,
248
referencedClassFile.getName(),
249
referencedMemberInfo.getName(referencedClassFile),
250
referencedMemberInfo.getDescriptor(referencedClassFile),
252
referencedMemberInfo);
334
257
* Finds or creates a InterfaceMethodrefCpInfo constant pool entry with the
335
258
* given class constant pool entry index, method name, and descriptor, in
336
259
* the given class file.
320
* Finds or creates a MethodrefCpInfo constant pool entry for the given
321
* class and method, in the given class file.
322
* @return the constant pool index of the MethodrefCpInfo.
324
public int addMethodrefCpInfo(ProgramClassFile programClassFile,
325
ClassFile referencedClassFile,
326
MemberInfo referencedMemberInfo)
328
return addMethodrefCpInfo(programClassFile,
329
referencedClassFile.getName(),
330
referencedMemberInfo.getName(referencedClassFile),
331
referencedMemberInfo.getDescriptor(referencedClassFile),
333
referencedMemberInfo);
338
* Finds or creates a MethodrefCpInfo constant pool entry with the given
339
* class name, method name, and descriptor, in the given class file.
340
* @return the constant pool index of the MethodrefCpInfo.
342
public int addMethodrefCpInfo(ProgramClassFile programClassFile,
346
ClassFile referencedClassFile,
347
MemberInfo referencedMemberInfo)
349
return addMethodrefCpInfo(programClassFile,
351
addNameAndTypeCpInfo(programClassFile,
355
referencedMemberInfo);
360
* Finds or creates a MethodrefCpInfo constant pool entry with the given
361
* class name, method name, and descriptor, in the given class file.
362
* @return the constant pool index of the MethodrefCpInfo.
364
public int addMethodrefCpInfo(ProgramClassFile programClassFile,
366
int nameAndTypeIndex,
367
ClassFile referencedClassFile,
368
MemberInfo referencedMemberInfo)
370
return addMethodrefCpInfo(programClassFile,
371
addClassCpInfo(programClassFile,
373
referencedClassFile),
376
referencedMemberInfo);
381
* Finds or creates a MethodrefCpInfo constant pool entry with the given
382
* class constant pool entry index, method name, and descriptor, in the
384
* @return the constant pool index of the MethodrefCpInfo.
386
public int addMethodrefCpInfo(ProgramClassFile programClassFile,
390
ClassFile referencedClassFile,
391
MemberInfo referencedMemberInfo)
393
return addMethodrefCpInfo(programClassFile,
395
addNameAndTypeCpInfo(programClassFile,
399
referencedMemberInfo);
404
* Finds or creates a MethodrefCpInfo constant pool entry with the given
405
* class constant pool entry index and name and type constant pool entry index
406
* the given class file.
407
* @return the constant pool index of the MethodrefCpInfo.
409
public int addMethodrefCpInfo(ProgramClassFile programClassFile,
411
int nameAndTypeIndex,
412
ClassFile referencedClassFile,
413
MemberInfo referencedMemberInfo)
415
CpInfo[] constantPool = programClassFile.constantPool;
416
int constantPoolCount = programClassFile.u2constantPoolCount;
418
// Check if the entry already exists.
419
for (int index = 1; index < constantPoolCount; index++)
421
CpInfo cpInfo = constantPool[index];
423
if (cpInfo != null &&
424
cpInfo.getTag() == ClassConstants.CONSTANT_Methodref)
426
MethodrefCpInfo methodrefCpInfo = (MethodrefCpInfo)cpInfo;
427
if (methodrefCpInfo.u2classIndex == classIndex &&
428
methodrefCpInfo.u2nameAndTypeIndex == nameAndTypeIndex)
435
return addCpInfo(programClassFile,
436
new MethodrefCpInfo(classIndex,
439
referencedMemberInfo));
444
* Finds or creates a ClassCpInfo constant pool entry for the given class,
445
* in the given class file.
446
* @return the constant pool index of the ClassCpInfo.
448
public int addClassCpInfo(ProgramClassFile programClassFile,
449
ClassFile referencedClassFile)
451
return addClassCpInfo(programClassFile,
452
referencedClassFile.getName(),
453
referencedClassFile);
399
458
* Finds or creates a ClassCpInfo constant pool entry with the given name,
400
459
* in the given class file.
401
460
* @return the constant pool index of the ClassCpInfo.
467
525
return addCpInfo(programClassFile,
468
526
new NameAndTypeCpInfo(nameIndex,
470
referencedClassFiles));
475
* Finds or creates an Utf8CpInfo constant pool entry for the given string,
532
* Finds or creates a Utf8CpInfo constant pool entry for the given string,
476
533
* in the given class file.
477
534
* @return the constant pool index of the Utf8CpInfo.
479
536
public int addUtf8CpInfo(ProgramClassFile programClassFile,
482
CpInfo[] constantPool = programClassFile.constantPool;
539
CpInfo[] constantPool = programClassFile.constantPool;
483
540
int constantPoolCount = programClassFile.u2constantPoolCount;
485
542
// Check if the entry already exists.