Search in sources :

Example 1 with ParameterAnnotationsAttribute

use of javassist.bytecode.ParameterAnnotationsAttribute in project audit4j-core by audit4j.

the class AnnotationDB method scanMethods.

/**
 * Scanns both the method and its parameters for annotations.
 *
 * @param cf
 */
protected void scanMethods(ClassFile cf) {
    List<ClassFile> methods = cf.getMethods();
    if (methods == null)
        return;
    for (Object obj : methods) {
        MethodInfo method = (MethodInfo) obj;
        if (scanMethodAnnotations) {
            AnnotationsAttribute visible = (AnnotationsAttribute) method.getAttribute(AnnotationsAttribute.visibleTag);
            AnnotationsAttribute invisible = (AnnotationsAttribute) method.getAttribute(AnnotationsAttribute.invisibleTag);
            if (visible != null)
                populate(visible.getAnnotations(), cf.getName());
            if (invisible != null)
                populate(invisible.getAnnotations(), cf.getName());
        }
        if (scanParameterAnnotations) {
            ParameterAnnotationsAttribute paramsVisible = (ParameterAnnotationsAttribute) method.getAttribute(ParameterAnnotationsAttribute.visibleTag);
            ParameterAnnotationsAttribute paramsInvisible = (ParameterAnnotationsAttribute) method.getAttribute(ParameterAnnotationsAttribute.invisibleTag);
            if (paramsVisible != null && paramsVisible.getAnnotations() != null) {
                for (Annotation[] anns : paramsVisible.getAnnotations()) {
                    populate(anns, cf.getName());
                }
            }
            if (paramsInvisible != null && paramsInvisible.getAnnotations() != null) {
                for (Annotation[] anns : paramsInvisible.getAnnotations()) {
                    populate(anns, cf.getName());
                }
            }
        }
    }
}
Also used : ClassFile(javassist.bytecode.ClassFile) ParameterAnnotationsAttribute(javassist.bytecode.ParameterAnnotationsAttribute) ParameterAnnotationsAttribute(javassist.bytecode.ParameterAnnotationsAttribute) AnnotationsAttribute(javassist.bytecode.AnnotationsAttribute) MethodInfo(javassist.bytecode.MethodInfo) Annotation(javassist.bytecode.annotation.Annotation)

Aggregations

AnnotationsAttribute (javassist.bytecode.AnnotationsAttribute)1 ClassFile (javassist.bytecode.ClassFile)1 MethodInfo (javassist.bytecode.MethodInfo)1 ParameterAnnotationsAttribute (javassist.bytecode.ParameterAnnotationsAttribute)1 Annotation (javassist.bytecode.annotation.Annotation)1