Java Code Examples for org.apache.bcel.classfile.JavaClass#getInterfaces()

The following examples show how to use org.apache.bcel.classfile.JavaClass#getInterfaces() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResolveAllReferences.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
private boolean find(JavaClass target, String name, String signature) throws ClassNotFoundException {
    if (target == null) {
        return false;
    }
    String ref = getMemberName(target.getClassName(), name, signature);
    if (defined.contains(ref)) {
        return true;
    }
    if (find(target.getSuperClass(), name, signature)) {
        return true;
    }
    for (JavaClass i : target.getInterfaces()) {
        if (find(i, name, signature)) {
            return true;
        }
    }
    return false;
}
 
Example 2
Source File: Hierarchy.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static @CheckForNull JavaClassAndMethod findInvocationLeastUpperBound(JavaClass jClass, String methodName, String methodSig,
        JavaClassAndMethodChooser methodChooser, boolean invokeInterface) throws ClassNotFoundException {
    JavaClassAndMethod result = findMethod(jClass, methodName, methodSig, methodChooser);
    if (result != null) {
        return result;
    }
    if (invokeInterface) {
        for (JavaClass i : jClass.getInterfaces()) {
            result = findInvocationLeastUpperBound(i, methodName, methodSig, methodChooser, invokeInterface);
            if (result != null) {
                return null;
            }
        }
    } else {
        JavaClass sClass = jClass.getSuperClass();
        if (sClass != null) {
            return findInvocationLeastUpperBound(sClass, methodName, methodSig, methodChooser, invokeInterface);
        }
    }
    return null;

}
 
Example 3
Source File: UncallableMethodOfAnonymousClass.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
boolean definedInSuperClassOrInterface(JavaClass clazz, String method) throws ClassNotFoundException {
    if (clazz == null) {
        return false;
    }
    JavaClass superClass = clazz.getSuperClass();
    if (superClass == null) {
        return false;
    }
    try {
        XClass xClass = Global.getAnalysisCache().getClassAnalysis(XClass.class,
                DescriptorFactory.createClassDescriptorFromDottedClassName(superClass.getClassName()));
        if (xClass.hasStubs()) {
            return true;
        }
    } catch (CheckedAnalysisException e) {
        return true;
    }

    if (definedInThisClassOrSuper(superClass, method)) {
        return true;
    }
    for (JavaClass i : clazz.getInterfaces()) {
        if (definedInThisClassOrSuper(i, method)) {
            return true;
        }
    }
    return false;
}