Search in sources :

Example 1 with MemberInformation

use of com.newrelic.weave.utils.ClassInformation.MemberInformation in project newrelic-java-agent by newrelic.

the class Reference method addMethodsAndFields.

/**
 * Fetch all methods and fields of a class node including those inherited from supertypes+interfaces. The results
 * will be stored in the passed in methods and fields lists.
 *
 * @param classCache Cache to use to fetch supertype resources
 * @param classNode The node to scan
 * @param methods classNode's methods will be appended to this list.
 * @param fields classNode's fields will be appended to this list.
 */
private static void addMethodsAndFields(ClassCache classCache, ClassNode classNode, List<MethodNode> methods, List<FieldNode> fields) throws IOException {
    ClassInformation classInfo = classCache.getClassInformation(classNode.name);
    for (MemberInformation methodInfo : classInfo.getAllMethods(classCache)) {
        MethodNode methodNode = new SynchronizedMethodNode();
        methodNode.name = methodInfo.name;
        methodNode.desc = methodInfo.desc;
        methodNode.access = methodInfo.access;
        methods.add(methodNode);
    }
    for (MemberInformation fieldInfo : classInfo.getAllFields(classCache)) {
        fields.add(new SynchronizedFieldNode(WeaveUtils.ASM_API_LEVEL, fieldInfo.access, fieldInfo.name, fieldInfo.desc, null, null));
    }
}
Also used : ClassInformation(com.newrelic.weave.utils.ClassInformation) MethodNode(org.objectweb.asm.tree.MethodNode) SynchronizedMethodNode(com.newrelic.weave.utils.SynchronizedMethodNode) SynchronizedMethodNode(com.newrelic.weave.utils.SynchronizedMethodNode) MemberInformation(com.newrelic.weave.utils.ClassInformation.MemberInformation) SynchronizedFieldNode(com.newrelic.weave.utils.SynchronizedFieldNode)

Aggregations

ClassInformation (com.newrelic.weave.utils.ClassInformation)1 MemberInformation (com.newrelic.weave.utils.ClassInformation.MemberInformation)1 SynchronizedFieldNode (com.newrelic.weave.utils.SynchronizedFieldNode)1 SynchronizedMethodNode (com.newrelic.weave.utils.SynchronizedMethodNode)1 MethodNode (org.objectweb.asm.tree.MethodNode)1