Package edu.umd.cs.findbugs.classfile

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


     */
    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
View Full Code Here


    public void addDefaultAnnotation(Target target, String c, NullnessAnnotation n) {
        if (DEBUG) {
            System.out.println("addDefaultAnnotation: target=" + target + ", c=" + c + ", n=" + n);
        }

        ClassDescriptor classDesc = DescriptorFactory.instance().getClassDescriptorForDottedClassName(c);
        ClassInfo xclass;

        // Get the XClass (really a ClassInfo object)
        try {
            xclass = (ClassInfo) Global.getAnalysisCache().getClassAnalysis(XClass.class, classDesc);
        } catch (MissingClassException e) {
            // AnalysisContext.currentAnalysisContext().getLookupFailureCallback().reportMissingClass(e.getClassDescriptor());
            return;
        } catch (CheckedAnalysisException e) {
            // AnalysisContext.logError("Error adding built-in nullness annotation",
            // e);
            return;
        }
        if (n == NullnessAnnotation.NONNULL && target == AnnotationDatabase.Target.PARAMETER) {
            xclass.addAnnotation(new AnnotationValue(PARAMETERS_ARE_NONNULL_BY_DEFAULT));
            return;
        } else if (n == NullnessAnnotation.NONNULL && target == AnnotationDatabase.Target.METHOD) {
            xclass.addAnnotation(new AnnotationValue(RETURN_VALUES_ARE_NONNULL_BY_DEFAULT));
            return;
        }
        // Get the default annotation type
        ClassDescriptor defaultAnnotationType;
        if (target == AnnotationDatabase.Target.ANY) {
            defaultAnnotationType = FindBugsDefaultAnnotations.DEFAULT_ANNOTATION;
        } else if (target == AnnotationDatabase.Target.FIELD) {
            defaultAnnotationType = FindBugsDefaultAnnotations.DEFAULT_ANNOTATION_FOR_FIELDS;
        } else if (target == AnnotationDatabase.Target.METHOD) {
            defaultAnnotationType = FindBugsDefaultAnnotations.DEFAULT_ANNOTATION_FOR_METHODS;
        } else if (target == AnnotationDatabase.Target.PARAMETER) {
            defaultAnnotationType = FindBugsDefaultAnnotations.DEFAULT_ANNOTATION_FOR_PARAMETERS;
        } else {
            throw new IllegalArgumentException("Unknown target for default annotation: " + target);
        }

        // Get the JSR-305 nullness annotation type
        ClassDescriptor nullnessAnnotationType = getNullnessAnnotationClassDescriptor(n);

        // Construct an AnnotationValue containing the default annotation
        AnnotationValue annotationValue = new AnnotationValue(defaultAnnotationType);
        AnnotationVisitor v = annotationValue.getAnnotationVisitor();
        v.visit("value", Type.getObjectType(nullnessAnnotationType.getClassName()));
        v.visitEnd();

        if (DEBUG) {
            System.out.println("Adding AnnotationValue " + annotationValue + " to class " + xclass);
        }
View Full Code Here

            }
            return;
        }

        // Get JSR-305 nullness annotation type
        ClassDescriptor nullnessAnnotationType = getNullnessAnnotationClassDescriptor(annotation);

        // Create an AnnotationValue
        AnnotationValue annotationValue = new AnnotationValue(nullnessAnnotationType);

        // Destructively add the annotation to the FieldInfo object
View Full Code Here

        ((FieldInfo) xfield).addAnnotation(annotationValue);
    }

    public @CheckForNull
    XMethod getXMethod(String cName, String mName, String sig, boolean isStatic) {
        ClassDescriptor classDesc = DescriptorFactory.instance().getClassDescriptorForDottedClassName(cName);
        ClassInfo xclass;

        // Get the XClass (really a ClassInfo object)
        try {
            xclass = (ClassInfo) Global.getAnalysisCache().getClassAnalysis(XClass.class, classDesc);
View Full Code Here

        XMethod xmethod = getXMethod(cName, mName, sig, isStatic);
        if (xmethod == null) {
            return;
        }
        // Get JSR-305 nullness annotation type
        ClassDescriptor nullnessAnnotationType = getNullnessAnnotationClassDescriptor(annotation);

        // Create an AnnotationValue
        AnnotationValue annotationValue = new AnnotationValue(nullnessAnnotationType);

        // Destructively add the annotation to the MethodInfo object
View Full Code Here

        XMethod xmethod = getXMethod(cName, mName, sig, isStatic);
        if (xmethod == null) {
            return;
        }
        // Get JSR-305 nullness annotation type
        ClassDescriptor nullnessAnnotationType = getNullnessAnnotationClassDescriptor(annotation);

        // Create an AnnotationValue
        AnnotationValue annotationValue = new AnnotationValue(nullnessAnnotationType);

        if (!xmethod.getClassName().equals(cName)) {
View Full Code Here

                return result;
            }
            if (isStatic) {
                throw new CheckedAnalysisException();
            }
            ClassDescriptor superclassDescriptor = xClass.getSuperclassDescriptor();
            if (superclassDescriptor == null) {
                throw new CheckedAnalysisException();
            }
            xClass = cache.getClassAnalysis(XClass.class, superclassDescriptor);
        }
View Full Code Here

                if (Hierarchy.isSubtype(expectedType, GWT_JAVASCRIPTOBJECT_TYPE)
                        && Hierarchy.isSubtype(actualType, GWT_JAVASCRIPTOBJECT_TYPE)) {
                    return SEEMS_OK;
                }
                // See if the types are related by inheritance.
                ClassDescriptor lhsDescriptor = DescriptorFactory.createClassDescriptorFromDottedClassName(expectedType
                        .getClassName());
                ClassDescriptor rhsDescriptor = DescriptorFactory.createClassDescriptorFromDottedClassName(actualType
                        .getClassName());

                return getPriorityForAssumingCompatible(pointerEquality, lhsDescriptor, rhsDescriptor);
            }
View Full Code Here

        this.isExclusive = isExclusive1;
        this.isExhaustive = isExhaustive1;


        if (xclass != null) {
            ClassDescriptor checkerName = DescriptorFactory.createClassDescriptor(typeQualifier.getClassName() + "$Checker");

            if (!SystemProperties.RUNNING_IN_ECLIPSE) {
                /**   don't do this if running in Eclipse; check below is the quick
                fix for bug 3599258 (Random obscure Eclipse failures during
                 analysis) */

                try {
                    Global.getAnalysisCache().getClassAnalysis(ClassData.class, checkerName);

                    // found it.
                    SecurityManager m = System.getSecurityManager();
                    if (m == null) {
                        if (DEBUG_CLASSLOADING) {
                            System.out.println("Setting ValidationSecurityManager");
                        }
                        System.setSecurityManager(ValidationSecurityManager.INSTANCE);
                    }

                    Class<?> c = ValidatorClassLoader.INSTANCE.loadClass(checkerName.getDottedClassName());
                    if (TypeQualifierValidator.class.isAssignableFrom(c)) {

                        @SuppressWarnings("unchecked")
                        Class<? extends TypeQualifierValidator<A>> validatorClass = (Class<? extends TypeQualifierValidator<A>>) c
                        .asSubclass(TypeQualifierValidator.class);
View Full Code Here

        ValidatorClassLoader validatorLoader = ValidatorClassLoader.INSTANCE;
        return (Class<A>) validatorLoader.loadClass(typeQualifier.getDottedClassName());
    }

    static byte[] loadClassData(String name) throws CheckedAnalysisException {
        ClassDescriptor d = DescriptorFactory.createClassDescriptorFromDottedClassName(name);
        ClassData data = Global.getAnalysisCache().getClassAnalysis(ClassData.class, d);
        return data.getData();
    }
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.