KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > alt > jiapi > reflect > ConstantPoolHelper


1 package alt.jiapi.reflect;
2
3 import alt.jiapi.file.ConstantPool;
4 import alt.jiapi.file.Field;
5
6 /**
7  * Class ConstantPoolHelper.
8  *
9  * @author Mika Riekkinen
10  */

11 class ConstantPoolHelper {
12     static short addMethodReference(ConstantPool cp, String JavaDoc className,
13                                     String JavaDoc methodName, Signature signature) {
14         // Add Class_info to constant pool
15
ConstantPool.ClassInfo ci = cp.addClassInfo(className);
16
17         // Add methodRef_info into constant pool
18
ConstantPool.MethodRefInfo mri =
19             cp.addMethodRefInfo(ci, methodName, signature.getDescriptor());
20
21         return mri.getEntryIndex();
22     }
23
24
25     static short addReference(ConstantPool cp, JiapiMethod jm) {
26         return addMethodReference(cp, jm.getDeclaringClass().getName(),
27                                   jm.getName(), jm.getSignature());
28     }
29
30
31
32     static short addFieldReference(ConstantPool cp, String JavaDoc className,
33                                    String JavaDoc fieldName, String JavaDoc descriptor) {
34         // Add Class_info to constant pool
35
ConstantPool.ClassInfo ci = cp.addClassInfo(className);
36
37         // Add fieldRef_info into constant pool
38
ConstantPool.FieldRefInfo fri =
39             cp.addFieldRefInfo(ci, fieldName, descriptor);
40
41         return fri.getEntryIndex();
42     }
43
44
45     static short addReference(ConstantPool cp, JiapiField jf) {
46         return addFieldReference(cp, jf.getDeclaringClass().getName(),
47                                  jf.getName(), jf.getDescriptor());
48     }
49 }
50
Popular Tags