Search in sources :

Example 1 with ElementValue

use of org.apache.bcel.classfile.ElementValue in project fb-contrib by mebigfatguy.

the class UnsynchronizedSingletonFieldWrites method isSingleton.

private boolean isSingleton(JavaClass cls) {
    if (cls.isEnum()) {
        return true;
    }
    AnnotationEntry[] annotations = cls.getAnnotationEntries();
    if (CollectionUtils.isEmpty(annotations)) {
        return false;
    }
    boolean isSpringBean = false;
    for (AnnotationEntry annotation : annotations) {
        String type = annotation.getAnnotationType();
        if (SPRING_CLASS_ANNOTATIONS.contains(type)) {
            isSpringBean = true;
        } else if (SPRING_SCOPE_ANNOTATION.equals(type)) {
            ElementValuePair[] pairs = annotation.getElementValuePairs();
            if (!CollectionUtils.isEmpty(pairs)) {
                for (ElementValuePair pair : pairs) {
                    String propName = pair.getNameString();
                    if ("value".equals(propName) || "scopeName".equals(propName)) {
                        ElementValue value = pair.getValue();
                        return "singleton".equals(value.stringifyValue());
                    }
                }
            }
        }
    }
    return isSpringBean;
}
Also used : AnnotationEntry(org.apache.bcel.classfile.AnnotationEntry) ElementValuePair(org.apache.bcel.classfile.ElementValuePair) ElementValue(org.apache.bcel.classfile.ElementValue)

Example 2 with ElementValue

use of org.apache.bcel.classfile.ElementValue in project fb-contrib by mebigfatguy.

the class FindClassCircularDependencies method visitAnnotation.

@Override
public void visitAnnotation(@DottedClassName String annotationClass, Map<String, ElementValue> map, boolean runtimeVisible) {
    if (!runtimeVisible) {
        return;
    }
    for (ElementValue v : map.values()) {
        if (v.getElementValueType() == ElementValue.CLASS) {
            String annotationClsAttr = SignatureUtils.stripSignature(v.stringifyValue());
            Set<String> dependencies = getDependenciesForClass(className);
            dependencies.add(annotationClsAttr);
        }
    }
}
Also used : ToString(com.mebigfatguy.fbcontrib.utils.ToString) ElementValue(org.apache.bcel.classfile.ElementValue)

Aggregations

ElementValue (org.apache.bcel.classfile.ElementValue)2 ToString (com.mebigfatguy.fbcontrib.utils.ToString)1 AnnotationEntry (org.apache.bcel.classfile.AnnotationEntry)1 ElementValuePair (org.apache.bcel.classfile.ElementValuePair)1