Package edu.umd.cs.findbugs.ba

Examples of edu.umd.cs.findbugs.ba.XClass


    private ClassVertex optionallyResolveClassVertex(ClassDescriptor classDescriptor) {
        ClassVertex typeVertex = classDescriptorToVertexMap.get(classDescriptor);
        if (typeVertex == null) {
            // We have never tried to resolve this ClassVertex before.
            // Try to find the XClass for this class.
            XClass xclass = AnalysisContext.currentXFactory().getXClass(classDescriptor);
            if (xclass == null) {
                // Class we're trying to resolve doesn't exist.
                // XXX: unfortunately, we don't know if the missing class is a
                // class or interface
                typeVertex = addClassVertexForMissingClass(classDescriptor, false);
View Full Code Here


     * @param workList
     *            work list of ClassVertexes that need to have their supertype
     *            edges added
     */
    private void addSupertypeEdges(ClassVertex vertex, LinkedList<XClass> workList) {
        XClass xclass = vertex.getXClass();

        // Direct superclass
        ClassDescriptor superclassDescriptor = xclass.getSuperclassDescriptor();
        if (superclassDescriptor != null) {
            addInheritanceEdge(vertex, superclassDescriptor, false, workList);
        }

        // Directly implemented interfaces
        for (ClassDescriptor ifaceDesc : xclass.getInterfaceDescriptorList()) {
            addInheritanceEdge(vertex, ifaceDesc, true, workList);
        }
    }
View Full Code Here

        ClassVertex superclassVertex = classDescriptorToVertexMap.get(superclassDescriptor);
        if (superclassVertex == null) {
            // Haven't encountered this class previously.

            XClass superclassXClass = AnalysisContext.currentXFactory().getXClass(superclassDescriptor);
            if (superclassXClass == null) {
                // Inheritance graph will be incomplete.
                // Add a dummy node to inheritance graph and report missing
                // class.
                superclassVertex = addClassVertexForMissingClass(superclassDescriptor, isInterfaceEdge);
View Full Code Here

        boolean isExclusive1 = false;
        /** will be set to true if this is an exhaustive type qualifier value */
        boolean isExhaustive1 = false;
        TypeQualifierValidator<A> validator1 = null;
        Class<A> qualifierClass = null;
        XClass xclass  = null;
        A proxy1 = null;
        try {
            xclass = Global.getAnalysisCache().getClassAnalysis(XClass.class, typeQualifier);

            // Annotation elements appear as abstract methods in the annotation
            // class (interface).
            // So, if the type qualifier annotation has specified a default When
            // value,
            // it will appear as an abstract method called "when".
            XMethod whenMethod = xclass.findMethod("when", "()Ljavax/annotation/meta/When;", false);
            if (whenMethod == null) {
                isStrict1 = true;
            }
            for (XMethod xmethod : xclass.getXMethods()) {
                if (xmethod.getName().equals("value") && xmethod.getSignature().startsWith("()")) {
                    isExhaustive1 = xmethod.getAnnotation(EXHAUSTIVE_ANNOTATION) != null;
                    if (isExhaustive1) {
                        // exhaustive qualifiers are automatically exclusive
                        isExclusive1 = true;
View Full Code Here

        boolean stopAtClassScope = false;

        if (!xmethod.isPublic() && !xmethod.isProtected() && (xmethod.isStatic() || xmethod.getName().equals("<init>"))) {
            try {
                XClass xclass = Global.getAnalysisCache().getClassAnalysis(XClass.class, xmethod.getClassDescriptor());
                stopAtClassScope = xclass.isPrivate();
            } catch (CheckedAnalysisException e) {
                AnalysisContext.logError("Problem resolving class for " + xmethod, e);
            }
        }
View Full Code Here

                if (annotationClass.equals(eclipseNonNull) || annotationClass.equals(eclipseNonNullByDefault)) {
                    resolveTypeQualifierNicknames(new AnnotationValue(JSR305NullnessAnnotations.NONNULL), result, onStack);
                    return;
                }

                XClass c = Global.getAnalysisCache().getClassAnalysis(XClass.class, annotationClass);
                if (c.getAnnotationDescriptors().contains(typeQualifierNickname)) {
                    for (ClassDescriptor d : c.getAnnotationDescriptors()) {
                        if (!d.equals(typeQualifierNickname)) {
                            resolveTypeQualifierNicknames(c.getAnnotation(d), result, onStack);
                        }
                    }
                } else if (c.getAnnotationDescriptors().contains(typeQualifier)) {
                    result.add(value);
                }
            } catch (MissingClassException e) {
                logMissingAnnotationClass(e);
                return;
View Full Code Here

     */
    private static void resolveTypeQualifierDefaults(AnnotationValue value, ElementType defaultFor,
            LinkedList<AnnotationValue> result) {

        try {
            XClass c = Global.getAnalysisCache().getClassAnalysis(XClass.class, value.getAnnotationClass());
            AnnotationValue defaultAnnotation = c.getAnnotation(typeQualifierDefault);
            if (defaultAnnotation == null) {
                return;
            }
            for (Object o : (Object[]) defaultAnnotation.getValue("value")) {
                if (o instanceof EnumValue) {
                    EnumValue e = (EnumValue) o;
                    if (e.desc.equals(elementTypeDescriptor) && e.value.equals(defaultFor.name())) {
                        for (ClassDescriptor d : c.getAnnotationDescriptors()) {
                            if (!d.equals(typeQualifierDefault)) {
                                resolveTypeQualifierNicknames(c.getAnnotation(d), result, new LinkedList<ClassDescriptor>());
                            }
                        }
                        break;
                    }
                }
View Full Code Here

                            continue;
                        }
                        if (!classDescriptor.getClassName().startsWith("java/util/concurrent")) {
                            continue;
                        }
                        XClass c = Lookup.getXClass(classDescriptor);
                        XMethod m;
                        int priority = NORMAL_PRIORITY;
                        if (methodName.equals("wait")) {
                            m = c.findMethod("await", "()V", false);
                            priority = HIGH_PRIORITY;
                        } else if (methodName.equals("notify")) {
                            m = c.findMethod("signal", "()V", false);
                            if (m == null) {
                                m = c.findMethod("countDown", "()V", false);
                            }
                        } else if (methodName.equals("notifyAll")) {
                            m = c.findMethod("signalAll", "()V", false);
                            if (m == null) {
                                m = c.findMethod("countDown", "()V", false);
                            }
                        } else {
                            throw new IllegalStateException("Unexpected methodName: " + methodName);
                        }

                        if (m != null && m.isPublic() && c.isPublic()) {
                            bugReporter.reportBug(new BugInstance(this, "JML_JSR166_CALLING_WAIT_RATHER_THAN_AWAIT", priority)
                            .addClassAndMethod(classContext.getJavaClass(), method).addCalledMethod(cpg, iv).addMethod(m)
                            .describe(MethodAnnotation.METHOD_ALTERNATIVE_TARGET).addType(classDescriptor)
                            .describe(TypeAnnotation.FOUND_ROLE).addSourceLine(classContext, method, location));
                        }
View Full Code Here

                // has default annotations applied which conflicts with parent class contract)
            }

            // 2 look in the hierarchy if we have relaxed contract
            HierarchyIterator hierarchy = new HierarchyIterator(xclass);
            XClass superClass;
            boolean done = false;
            while (!done && (superClass = hierarchy.next()) != null) {
                XMethod method = superClass.findMethod(name, desc, false);
                if (method != null) {
                    done = checkMethod(method);
                } else {
                    for (XMethod superMethod : superClass.getXMethods()) {
                        if (name.equals(superMethod.getName()) && compatibleParameters(desc, superMethod.getSignature())) {
                            if (checkMethod(superMethod)) {
                                done = true;
                                break;
                            }
View Full Code Here

        public XClass next() {
            while (!interfacesToVisit.isEmpty()) {
                ClassDescriptor interfaceDescr = interfacesToVisit.poll();
                if (visited.add(interfaceDescr)) {
                    XClass xinterface = getClassInfo(interfaceDescr);
                    if(xinterface != null){
                        interfacesToVisit.addAll(Arrays.asList(xinterface.getInterfaceDescriptorList()));
                        return xinterface;
                    }
                }
            }
            // no interfaces => check super classes
            if (superclass == null) {
                return null;
            }
            XClass currentSuperclass = superclass;
            // compute next one
            superclass = getClassInfo(superclass.getSuperclassDescriptor());
            if(superclass != null){
                interfacesToVisit = new LinkedList<ClassDescriptor>(Arrays.asList(superclass.getInterfaceDescriptorList()));
            }
View Full Code Here

TOP

Related Classes of edu.umd.cs.findbugs.ba.XClass

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.