Package edu.umd.cs.findbugs.ba.ch

Examples of edu.umd.cs.findbugs.ba.ch.Subtypes2


                isCloneable = true;
                break;
            }
        }

        Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2();
        try {
            if (subtypes2.isSubtype(getClassDescriptor(), cloneDescriptor)) {
                isCloneable = true;
            }
            if (subtypes2.isSubtype(DescriptorFactory.createClassDescriptorFromDottedClassName(obj.getSuperclassName()),
                    cloneDescriptor)) {
                implementsCloneableDirectly = false;
            }

        } catch (ClassNotFoundException e) {
View Full Code Here


            int priority = LOW_PRIORITY;
            if (obj.isPublic() || obj.isProtected()) {
                priority = NORMAL_PRIORITY;
            }
            try {
                Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2();
                Set<ClassDescriptor> directSubtypes = subtypes2.getDirectSubtypes(getClassDescriptor());
                if (!directSubtypes.isEmpty()) {
                    priority--;
                }
                BugInstance bug = new BugInstance(this, "CN_IDIOM_NO_SUPER_CALL", priority).addClass(this).addMethod(
                        cloneMethodAnnotation);
View Full Code Here

        if (className.equals("java.util.concurrent.ConcurrentHashMap")
                || className.equals(concurrentMapDescriptor.getDottedClassName())) {
            return true;
        }
        ClassDescriptor c = DescriptorFactory.createClassDescriptorFromDottedClassName(className);
        Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2();

        try {
            if (subtypes2.isSubtype(c, concurrentMapDescriptor)) {
                return true;
            }
        } catch (ClassNotFoundException e) {
            AnalysisContext.reportMissingClass(e);
        }
View Full Code Here

        incrementField = null;
    }

    @Override
    public void report() {
        Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2();

        for (XField f : AnalysisContext.currentXFactory().allFields()) {
            if (isVolatileArray(f) && subtypes2.isApplicationClass(f.getClassDescriptor())) {
                int priority = LOW_PRIORITY;
                if (initializationWrites.contains(f) && !otherWrites.contains(f)) {
                    priority = NORMAL_PRIORITY;
                }
                bugReporter.reportBug(new BugInstance(this, "VO_VOLATILE_REFERENCE_TO_ARRAY", priority).addClass(
View Full Code Here

            return 1.0;
        }
        if (y.getClassName().equals("java.lang.Object")) {
            return 1.0;
        }
        Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2();
        ClassDescriptor xDesc = DescriptorFactory.createClassDescriptor(x);
        ClassDescriptor yDesc = DescriptorFactory.createClassDescriptor(y);

        boolean xIsSubtypeOfY = Repository.instanceOf(x, y);
        if (xIsSubtypeOfY) {
            return 1.0;
        }
        boolean yIsSubtypeOfX = Repository.instanceOf(y, x);
        if (!yIsSubtypeOfX) {
            if (x.isFinal() || y.isFinal()) {
                return 0.0;
            }
            if (!x.isInterface() && !y.isInterface()) {
                return 0.0;
            }
        }

        Set<ClassDescriptor> transitiveCommonSubtypes = subtypes2.getTransitiveCommonSubtypes(xDesc, yDesc);

        if (transitiveCommonSubtypes.isEmpty()) {
            for (ClassDescriptor c : subtypes2.getSubtypes(xDesc)) {
                XClass cx;
                try {
                    cx = Global.getAnalysisCache().getClassAnalysis(XClass.class, c);
                } catch (CheckedAnalysisException e) {
                    continue;
                }
                if (!cx.isAbstract() && !cx.isInterface()) {
                    if (x.isAbstract() || x.isInterface()) {
                        return 0.2;
                    }
                    return 0.1;
                }
            }
            return 0.3;
        }

        // exist classes that are both X and Y
        Set<ClassDescriptor> xButNotY = new HashSet<ClassDescriptor>(subtypes2.getSubtypes(xDesc));
        xButNotY.removeAll(transitiveCommonSubtypes);
        for (ClassDescriptor c : xButNotY) {

            try {
                XClass cx = Global.getAnalysisCache().getClassAnalysis(XClass.class, c);
View Full Code Here

        if (item.isInitialParameter() && item.getRegisterNumber() == 1) {
            ClassDescriptor thisClassDescriptor = getClassDescriptor();
            if (c.equals(thisClassDescriptor)) {
                return;
            }
            Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2();
            try {
                if (!c.isArray() && (subtypes2.isSubtype(c, thisClassDescriptor) || subtypes2.isSubtype(thisClassDescriptor, c))) {
                    return;
                }

                Type thisType = Type.getType(thisClassDescriptor.getSignature());
                Type cType = Type.getType(c.getSignature());
View Full Code Here

                ObligationPolicyDatabaseEntryType.STRONG, createdObligation));
    }

    private void scanForResourceTypes() {

        Subtypes2 subtypes2 = Global.getAnalysisCache().getDatabase(Subtypes2.class);
        Collection<XClass> knownClasses = subtypes2.getXClassCollection();

        for (XClass xclass : knownClasses) {
            // Is this class a resource type?
            if (xclass.getAnnotation(cleanupObligation) != null) {
                // Add it as an obligation type
View Full Code Here

        case INVOKEVIRTUAL:
        case INVOKESPECIAL:
        case INVOKESTATIC:
        case INVOKEINTERFACE:
            ClassDescriptor c = getClassDescriptorOperand();
            Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2();
            if (subtypes2.isApplicationClass(c)) {
                xFactory.addCalledMethod(getMethodDescriptorOperand());
            }

            break;
        default:
View Full Code Here

TOP

Related Classes of edu.umd.cs.findbugs.ba.ch.Subtypes2

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.