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

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


                return result;
            }
        }
        ClassDescriptor classDescriptor = DescriptorFactory.createClassDescriptor(x);

        Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2();

        Set<ClassDescriptor> directSubtypes = subtypes2.getDirectSubtypes(classDescriptor);
        directSubtypes.remove(classDescriptor);


        double confidence = 0.6;
        if (x.isAbstract() || x.isInterface()) {
View Full Code Here


    public boolean matches(Type t) {
        if (!(t instanceof ReferenceType)) {
            return false;
        }
        IAnalysisCache analysisCache = Global.getAnalysisCache();
        Subtypes2 subtypes2 = analysisCache.getDatabase(Subtypes2.class);

        try {
            return subtypes2.isSubtype((ReferenceType) t, supertype);
        } catch (ClassNotFoundException e) {
            analysisCache.getErrorLogger().reportMissingClass(e);
            return false;
        }
    }
View Full Code Here

        if (lhsDescriptor.equals(rhsDescriptor)) {
            return SEEMS_OK;
        }

        AnalysisContext analysisContext = AnalysisContext.currentAnalysisContext();
        Subtypes2 subtypes2 = analysisContext.getSubtypes2();

        IAnalysisCache cache = Global.getAnalysisCache();
        XClass lhs = cache.getClassAnalysis(XClass.class, lhsDescriptor);
        XClass rhs = cache.getClassAnalysis(XClass.class, rhsDescriptor);
        // Look up the classes
        XMethod lhsEquals = getInvokedMethod(lhs, "equals", "(Ljava/lang/Object;)Z", false);
        XMethod rhsEquals = getInvokedMethod(rhs, "equals", "(Ljava/lang/Object;)Z", false);
        String lhsClassName = lhsEquals.getClassName();
        if (lhsEquals.equals(rhsEquals)) {
            if (lhsClassName.equals("java.lang.Enum")) {
                return INCOMPATIBLE_CLASSES;
            }
            if (!pointerEquality && !lhsClassName.equals("java.lang.Object")) {
                return SEEMS_OK;
            }
        }

        if ((subtypes2.isSubtype(lhsDescriptor, SET_DESCRIPTOR) && subtypes2.isSubtype(rhsDescriptor, SET_DESCRIPTOR)
                || subtypes2.isSubtype(lhsDescriptor, MAP_DESCRIPTOR) && subtypes2.isSubtype(rhsDescriptor, MAP_DESCRIPTOR) || subtypes2
                .isSubtype(lhsDescriptor, LIST_DESCRIPTOR) && subtypes2.isSubtype(rhsDescriptor, LIST_DESCRIPTOR))) {
            return SEEMS_OK;
        }

        if (!lhs.isInterface() && !rhs.isInterface()) {
            // Both are class types, and therefore there is no possible
            // way
            // the compared objects can have the same runtime type.
            return INCOMPATIBLE_CLASSES;
        } else {

            // Look up the common subtypes of the two types. If the
            // intersection does not contain at least one
            // class,
            // then issue a warning of the appropriate type.
            Set<ClassDescriptor> commonSubtypes = subtypes2.getTransitiveCommonSubtypes(lhsDescriptor, rhsDescriptor);

            if (commonSubtypes.isEmpty()) {
                if (lhs.isInterface() && rhs.isInterface()) {
                    if (!subtypes2.hasKnownSubclasses(lhsDescriptor) || !subtypes2.hasKnownSubclasses(rhsDescriptor)) {
                        return UNRELATED_INTERFACES_WITHOUT_IMPLEMENTATIONS;
                    }
                    return UNRELATED_INTERFACES;
                }
                if (lhs.isFinal() || rhs.isFinal()) {
View Full Code Here

            return true;
        }

        ClassDescriptor c = m.getClassDescriptor();
        if (m.getName().startsWith("test") || m.getName().startsWith("assert")) {
            Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2();

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

            Collection<Info> collection = callMap.get(call);
            if (!callMap.containsKey(call)) {
                continue;
            }
            for(Info info : collection) {
                Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2();
                if (DEBUG) {
                    System.out.println("at " + handle.getPosition() + " Checking call to " + info.interfaceForCall + " : " + invokedMethod);
                }
                try {
                    if (!subtypes2.isSubtype(invokedMethod.getClassDescriptor(), info.interfaceForCall)) {
                        continue;
                    }
                } catch (ClassNotFoundException e) {
                    if (info.interfaceForCall.getClassName().equals("java/util/Collection")
                            && invokedMethod.getClassName().equals("com.google.common.collect.Multiset")) {
View Full Code Here

                int priority = LOW_PRIORITY;
                if (seenPutStatic || seenGetStatic) {
                    priority--;
                }
                try {
                    Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2();
                    Set<ClassDescriptor> directSubtypes = subtypes2.getDirectSubtypes(getClassDescriptor());
                    if (!directSubtypes.isEmpty()) {
                        for (ClassDescriptor sub : directSubtypes) {
                            pendingBug.addClass(sub).describe(ClassAnnotation.SUBCLASS_ROLE);
                        }
                        priority--;
View Full Code Here

                int args = PreorderVisitor.getNumberArguments(m.getSignature());
                OpcodeStack.Item item = stack.getStackItem(args);
                if (item.getRegisterNumber() == 0) {
                    try {
                        Set<XMethod> targets = Hierarchy2.resolveVirtualMethodCallTargets(m, false, false);
                        Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2();

                        for (XMethod called : targets) {
                            if (!called.isAbstract() && !called.equals(m)
                                    && subtypes2.isSubtype(called.getClassDescriptor(), getClassDescriptor())) {
                                fieldSummary.setCalledFromSuperConstructor(new ProgramPoint(this), called);
                            }
                        }
                    } catch (ClassNotFoundException e) {
                        AnalysisContext.reportMissingClass(e);
View Full Code Here

    public static boolean isServletField(XField field) {
        ClassDescriptor classDescriptor = field.getClassDescriptor();

        try {
            Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2();
            if (subtypes2.isSubtype(classDescriptor, servlet) && !subtypes2.isSubtype(classDescriptor, singleThreadedServlet)) {
                return true;
            }
        } catch (ClassNotFoundException e) {
            assert true;
        }
View Full Code Here

        }

        // Does this class indirectly implement Serializable?
        if ((!superClassIsObject || interface_names.length > 0) && !isSerializable) {
            try {
                Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2();
                ClassDescriptor desc = DescriptorFactory.createClassDescriptor(obj);
                if (subtypes2.getSubtypes(serializable).contains(desc) || subtypes2.getSubtypes(externalizable).contains(desc)
                        || subtypes2.getSubtypes(remote).contains(desc)) {
                    isSerializable = true;
                }
            } catch (ClassNotFoundException e) {
                bugReporter.reportMissingClass(e);
            }
View Full Code Here

                    XClass outerXClass = Global.getAnalysisCache().getClassAnalysis(XClass.class, cDesc);

                    AnalysisContext analysisContext = AnalysisContext.currentAnalysisContext();

                    Subtypes2 subtypes2 = analysisContext.getSubtypes2();

                    for (XField of : outerXClass.getXFields()) {
                        if (!of.isStatic()) {
                            String sourceSignature = of.getSourceSignature();
                            if (sourceSignature != null && of.getSignature().equals("Ljava/lang/ThreadLocal;")) {
                                Type ofType = GenericUtilities.getType(sourceSignature);
                                if (ofType instanceof GenericObjectType) {
                                    GenericObjectType gType = (GenericObjectType) ofType;

                                    for (ReferenceType r : gType.getParameters()) {
                                        if (r instanceof ObjectType) {
                                            ClassDescriptor c = DescriptorFactory.getClassDescriptor((ObjectType) r);
                                            if (subtypes2.isSubtype(f.getClassDescriptor(), c)) {
                                                ProgramPoint p = data.threadLocalAssignedInConstructor.get(of);
                                                int priority = p == null ? NORMAL_PRIORITY : HIGH_PRIORITY;
                                                BugInstance bug = new BugInstance(this, "SIC_THREADLOCAL_DEADLY_EMBRACE",
                                                        priority).addClass(className).addField(of);
                                                if (p != null) {
View Full Code Here

TOP

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

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.