Package edu.umd.cs.findbugs.classfile

Examples of edu.umd.cs.findbugs.classfile.ClassDescriptor


        public void setSourceSignature(String classSourceSignature) {
            this.classSourceSignature = classSourceSignature;
        }

        public void addAnnotation(String name, AnnotationValue value) {
            ClassDescriptor annotationClass = DescriptorFactory.createClassDescriptorFromSignature(name);
            classAnnotations.put(annotationClass, value);
        }
View Full Code Here


                || Subtypes2.instanceOf(className, " org.apache.jasper.runtime.JspSourceDependent");
    }

    public static boolean instanceOf(@DottedClassName String dottedSubtype, @DottedClassName String dottedSupertype) {
        Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2();
        ClassDescriptor subDescriptor = DescriptorFactory.createClassDescriptorFromDottedClassName(dottedSubtype);
        ClassDescriptor superDescriptor = DescriptorFactory.createClassDescriptorFromDottedClassName(dottedSupertype);
        try {
            return subtypes2.isSubtype(subDescriptor, superDescriptor);
        } catch (ClassNotFoundException e) {
            AnalysisContext.reportMissingClass(e);
            return false;
View Full Code Here

        return instanceOf(subDescriptor, c.getName());
    }

    public static boolean instanceOf(ClassDescriptor subDescriptor, @DottedClassName String dottedSupertype) {
        Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2();
        ClassDescriptor superDescriptor = DescriptorFactory.createClassDescriptorFromDottedClassName(dottedSupertype);
        try {
            return subtypes2.isSubtype(subDescriptor, superDescriptor);
        } catch (ClassNotFoundException e) {
            AnalysisContext.reportMissingClass(e);
            return false;
View Full Code Here

        }
        if (subtype.getSuperclassName().equals("java.lang.Object") && subtype.getInterfaceIndices().length == 0) {
            return false;
        }
        Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2();
        ClassDescriptor subDescriptor = DescriptorFactory.createClassDescriptor(subtype);
        ClassDescriptor superDescriptor = DescriptorFactory.createClassDescriptorFromDottedClassName(dottedSupertype);
        try {
            return subtypes2.isSubtype(subDescriptor, superDescriptor);
        } catch (ClassNotFoundException e) {
            AnalysisContext.reportMissingClass(e);
            return false;
View Full Code Here

                return true;
            }
        }
        XClass xclass = AnalysisContext.currentXFactory().getXClass(subDesc);
        if (xclass != null) {
            ClassDescriptor xSuper = xclass.getSuperclassDescriptor();
            for (ClassDescriptor s : superDesc) {
                if (s.equals(xSuper)) {
                    return true;
                }
            }
View Full Code Here

        //        if (true) {
        // XXX call below causes 88% of all MissingClassException thrown (20000 on java* JDK7 classes)
        XClass xclass = AnalysisContext.currentXFactory().getXClass(subDesc);
        if (xclass != null) {
            ClassDescriptor xSuper = xclass.getSuperclassDescriptor();
            if (superDesc.equals(xSuper)) {
                return true;
            }
            ClassDescriptor[] interfaces = xclass.getInterfaceDescriptorList();
            if (interfaces.length == 0) {
                if (xSuper == null) {
                    return false;
                }
                if (xSuper.getClassName().equals("java/lang/Object")) {
                    return false;
                }
            } else {
                for (ClassDescriptor i : interfaces) {
                    if (superDesc.equals(i)) {
View Full Code Here

            if (DEBUG_QUERIES) {
                System.out.println("  ==> yes, types are same");
            }
            return true;
        }
        ClassDescriptor typeClassDescriptor = DescriptorFactory.getClassDescriptor(type);
        ClassDescriptor possibleSuperclassClassDescriptor = DescriptorFactory.getClassDescriptor(possibleSupertype);

        return isSubtype(typeClassDescriptor, possibleSuperclassClassDescriptor);
    }
View Full Code Here

        return firstCommonSupertype;
    }

    private ObjectType computeFirstCommonSuperclassOfObjectTypes(ObjectType a, ObjectType b) throws ClassNotFoundException {
        ObjectType firstCommonSupertype;
        ClassDescriptor aDesc = DescriptorFactory.getClassDescriptor(a);
        ClassDescriptor bDesc = DescriptorFactory.getClassDescriptor(b);

        ClassVertex aVertex = resolveClassVertex(aDesc);
        ClassVertex bVertex = resolveClassVertex(bDesc);

        Set<ClassDescriptor> aSuperTypes = computeKnownSupertypes(aDesc);
        Set<ClassDescriptor> bSuperTypes = computeKnownSupertypes(bDesc);
        if (bSuperTypes.contains(aDesc)) {
            return a;
        }
        if (aSuperTypes.contains(bDesc)) {
            return b;
        }
        ArrayList<ClassVertex> aSuperList = getAllSuperclassVertices(aVertex);
        ArrayList<ClassVertex> bSuperList = getAllSuperclassVertices(bVertex);

        // Work backwards until the lists diverge.
        // The last element common to both lists is the first
        // common superclass.
        int aIndex = aSuperList.size() - 1;
        int bIndex = bSuperList.size() - 1;

        ClassVertex lastCommonInBackwardsSearch = null;
        while (aIndex >= 0 && bIndex >= 0) {
            if (aSuperList.get(aIndex) != bSuperList.get(bIndex)) {
                break;
            }
            lastCommonInBackwardsSearch = aSuperList.get(aIndex);
            aIndex--;
            bIndex--;
        }
        if (lastCommonInBackwardsSearch == null) {
            firstCommonSupertype = Type.OBJECT;
        } else {
            firstCommonSupertype = ObjectTypeFactory.getInstance(lastCommonInBackwardsSearch.getClassDescriptor()
                    .toDottedClassName());
        }
        if (firstCommonSupertype.equals(Type.OBJECT)) {
            // see if we can't do better
            ClassDescriptor objDesc = DescriptorFactory.getClassDescriptor(Type.OBJECT);
            aSuperTypes.retainAll(bSuperTypes);
            aSuperTypes.remove(objDesc);
            for (ClassDescriptor c : aSuperTypes) {
                if (c.getPackageName().equals(aDesc.getPackageName()) || c.getPackageName().equals(bDesc.getPackageName())) {
                    return ObjectTypeFactory.getInstance(c.toDottedClassName());
View Full Code Here

                // Unknown class - so, we don't know its immediate supertypes
                continue;
            }

            // Advance to direct superclass
            ClassDescriptor superclassDescriptor = vertex.getXClass().getSuperclassDescriptor();
            if (superclassDescriptor != null && traverseEdge(vertex, superclassDescriptor, false, visitor)) {
                addToWorkList(workList, cur, superclassDescriptor);
            }

            // Advance to directly-implemented interfaces
View Full Code Here

            // Visitor doesn't want to continue on this path
            return;
        }

        // Advance to direct superclass
        ClassDescriptor superclassDescriptor = vertex.getXClass().getSuperclassDescriptor();
        if (superclassDescriptor != null) {
            traverseSupertypesDepthFirstHelper(superclassDescriptor, visitor, seen);
        }

        // Advance to directly-implemented interfaces
View Full Code Here

TOP

Related Classes of edu.umd.cs.findbugs.classfile.ClassDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.