Search in sources :

Example 11 with Method

use of org.apache.bcel.classfile.Method in project jop by jop-devel.

the class ConstantPoolReferenceFinder method findPoolReferences.

////////////////////////////////////////////////////////////////
// Find/replace references, member names, Pool entries
////////////////////////////////////////////////////////////////
public static Set<Integer> findPoolReferences(ClassInfo classInfo, boolean checkMembers) {
    JavaClass javaClass = classInfo.compile();
    Set<Integer> ids = findPoolReferences(classInfo, javaClass);
    if (checkMembers) {
        for (Field field : javaClass.getFields()) {
            FieldInfo fieldInfo = classInfo.getFieldInfo(field.getName());
            ids.addAll(findPoolReferences(fieldInfo, field));
        }
        for (Method method : javaClass.getMethods()) {
            MethodInfo methodInfo = classInfo.getMethodInfo(method.getName() + method.getSignature());
            ids.addAll(findPoolReferences(methodInfo, method));
        }
    }
    return ids;
}
Also used : ConstantInteger(org.apache.bcel.classfile.ConstantInteger) Field(org.apache.bcel.classfile.Field) JavaClass(org.apache.bcel.classfile.JavaClass) MethodInfo(com.jopdesign.common.MethodInfo) ConstantMethodInfo(com.jopdesign.common.type.ConstantMethodInfo) Method(org.apache.bcel.classfile.Method) EnclosingMethod(com.jopdesign.common.bcel.EnclosingMethod) ConstantFieldInfo(com.jopdesign.common.type.ConstantFieldInfo) FieldInfo(com.jopdesign.common.FieldInfo)

Aggregations

Method (org.apache.bcel.classfile.Method)11 Field (org.apache.bcel.classfile.Field)5 ConstantPoolGen (org.apache.bcel.generic.ConstantPoolGen)4 JavaClass (org.apache.bcel.classfile.JavaClass)3 FieldInfo (com.jopdesign.common.FieldInfo)2 MethodInfo (com.jopdesign.common.MethodInfo)2 EnclosingMethod (com.jopdesign.common.bcel.EnclosingMethod)2 ConstantFieldInfo (com.jopdesign.common.type.ConstantFieldInfo)2 ConstantMethodInfo (com.jopdesign.common.type.ConstantMethodInfo)2 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 Constant (org.apache.bcel.classfile.Constant)2 ConstantInteger (org.apache.bcel.classfile.ConstantInteger)2 ConstantNameAndType (org.apache.bcel.classfile.ConstantNameAndType)2 CPInstruction (org.apache.bcel.generic.CPInstruction)2 InstructionHandle (org.apache.bcel.generic.InstructionHandle)2 InstructionList (org.apache.bcel.generic.InstructionList)2 MethodGen (org.apache.bcel.generic.MethodGen)2 Type (org.apache.bcel.generic.Type)2 InstructionFinder (org.apache.bcel.util.InstructionFinder)2