Package edu.umd.cs.findbugs.ba

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


            referencedPackageSet.add(classDesc.getPackageName());

            // Get list of referenced classes and add them to set.
            // Add superclasses and superinterfaces to worklist.
            try {
                XClass classNameAndInfo = Global.getAnalysisCache().getClassAnalysis(XClass.class, classDesc);

                ClassDescriptor superclassDescriptor = classNameAndInfo.getSuperclassDescriptor();
                if (superclassDescriptor != null && addedToWorkList.add(superclassDescriptor)) {
                    workList.addLast(superclassDescriptor);
                }

                for (ClassDescriptor ifaceDesc : classNameAndInfo.getInterfaceDescriptorList()) {
                    if (addedToWorkList.add(ifaceDesc)) {
                        workList.addLast(ifaceDesc);
                    }
                }

                ClassDescriptor enclosingClass = classNameAndInfo.getImmediateEnclosingClass();
                if (enclosingClass != null && addedToWorkList.add(enclosingClass)) {
                    workList.addLast(enclosingClass);
                }

            } catch (RuntimeException e) {
View Full Code Here


            progress.predictPassCount(classesPerPass);
            XFactory factory = AnalysisContext.currentXFactory();
            Collection<ClassDescriptor> badClasses = new LinkedList<ClassDescriptor>();
            for (ClassDescriptor desc : referencedClassSet) {
                try {
                    XClass info = Global.getAnalysisCache().getClassAnalysis(XClass.class, desc);
                    factory.intern(info);
                } catch (CheckedAnalysisException e) {
                    AnalysisContext.logError("Couldn't get class info for " + desc, e);
                    badClasses.add(desc);
                } catch (RuntimeException e) {
                    AnalysisContext.logError("Couldn't get class info for " + desc, e);
                    badClasses.add(desc);
                }
            }
            if (!badClasses.isEmpty()) {
                referencedClassSet = new LinkedHashSet<ClassDescriptor>(referencedClassSet);
                referencedClassSet.removeAll(badClasses);
            }

            long startTime = System.currentTimeMillis();
            bugReporter.getProjectStats().setReferencedClasses(referencedClassSet.size());
            for (Iterator<AnalysisPass> passIterator = executionPlan.passIterator(); passIterator.hasNext();) {
                AnalysisPass pass = passIterator.next();
                yourkitController.advanceGeneration("Pass " + passCount);
                // The first pass is generally a non-reporting pass which
                // gathers information about referenced classes.
                boolean isNonReportingFirstPass = multiplePasses && passCount == 0;

                // Instantiate the detectors
                Detector2[] detectorList = pass.instantiateDetector2sInPass(bugReporter);

                // If there are multiple passes, then on the first pass,
                // we apply detectors to all classes referenced by the
                // application classes.
                // On subsequent passes, we apply detector only to application
                // classes.
                Collection<ClassDescriptor> classCollection = (isNonReportingFirstPass) ? referencedClassSet : appClassList;
                AnalysisContext.currentXFactory().canonicalizeAll();
                if (PROGRESS || LIST_ORDER) {
                    System.out.printf("%6d : Pass %d: %d classes%n", (System.currentTimeMillis() - startTime)/1000, passCount,  classCollection.size());
                    if (DEBUG) {
                        XFactory.profile();
                    }
                }
                if (!isNonReportingFirstPass) {
                    OutEdges<ClassDescriptor> outEdges = new OutEdges<ClassDescriptor>() {

                        @Override
                        public Collection<ClassDescriptor> getOutEdges(ClassDescriptor e) {
                            try {
                                XClass classNameAndInfo = Global.getAnalysisCache().getClassAnalysis(XClass.class, e);
                                return classNameAndInfo.getCalledClassDescriptors();
                            } catch (CheckedAnalysisException e2) {
                                AnalysisContext.logError("error while analyzing " + e.getClassName(), e2);
                                return Collections.emptyList();

                            }
View Full Code Here

        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);
                if (!cx.isAbstract() && !cx.isInterface()) {
                    return 0.7;
                }
            } catch (CheckedAnalysisException e) {
                continue;
            }
View Full Code Here

            return;
        }

        IAnalysisCache analysisCache = Global.getAnalysisCache();

        XClass classInfo = analysisCache.getClassAnalysis(XClass.class, classDescriptor);

        // Test dataflow analysis on each method]
        for (XMethod xMethod : classInfo.getXMethods()) {
            if (methodName != null && !methodName.equals(xMethod.getName())) {
                continue;
            }
            MethodDescriptor methodDescriptor = xMethod.getMethodDescriptor();
View Full Code Here

    }

    @Override
    public void visitClass(ClassDescriptor classDescriptor) throws CheckedAnalysisException {

        XClass xclass = Global.getAnalysisCache().getClassAnalysis(XClass.class, classDescriptor);

        // Is this class an obligation type?
        Obligation thisClassObligation = database.getFactory().getObligationByType(xclass.getClassDescriptor());

        // Scan methods for uses of obligation-related annotations
        for (XMethod xmethod : xclass.getXMethods()) {
            // Is this method marked with @CreatesObligation?
            if (thisClassObligation != null) {
                if (xmethod.getAnnotation(createsObligation) != null) {
                    database.addEntry(new MatchMethodEntry(xmethod, ObligationPolicyDatabaseActionType.ADD,
                            ObligationPolicyDatabaseEntryType.STRONG, thisClassObligation));
View Full Code Here

        if (seen == INVOKESPECIAL) {
            XMethod m = getXMethodOperand();
            if (m == null) {
                return;
            }
            XClass c = getXClass();
            int nameDistance = EditDistance.editDistance(m.getName(), getMethodName());
            if (nameDistance < 4 && c.findMatchingMethod(m.getMethodDescriptor()) == null && !m.isFinal()) {
                potentialSuperCall = m;
            }
        }
    }
View Full Code Here

        JavaClass superClass = clazz.getSuperClass();
        if (superClass == null) {
            return false;
        }
        try {
            XClass xClass = Global.getAnalysisCache().getClassAnalysis(XClass.class,
                    DescriptorFactory.createClassDescriptorFromDottedClassName(superClass.getClassName()));
            if (xClass.hasStubs()) {
                return true;
            }
        } catch (CheckedAnalysisException e) {
            return true;
        }
View Full Code Here

                        AnalysisContext.reportMissingClass(e);
                    }
                }
                pendingBug.addClass(superclassName).describe(role);
                try {
                    XClass from = Global.getAnalysisCache().getClassAnalysis(XClass.class,
                            DescriptorFactory.createClassDescriptorFromDottedClassName(superclassName));
                    XMethod  potentialMatch = null;
                    for(XMethod m : from.getXMethods()) {
                        if (!m.isStatic() && !m.isPrivate() && m.getName().toLowerCase().equals(obj.getName().toLowerCase())) {
                            if (potentialMatch == null) {
                                potentialMatch = m;
                            } else {
                                // multiple matches; ignore all
View Full Code Here

            }
            if (lastDollar >= 0 && (fieldName.startsWith("this$") || fieldName.startsWith("this+"))) {
                String outerClassName = className.substring(0, lastDollar);

                try {
                    XClass thisClass = Global.getAnalysisCache().getClassAnalysis(XClass.class, f.getClassDescriptor());

                    if (isAnonymousInnerClass) {
                        for (XField f2 : thisClass.getXFields()) {
                            if (f2 != f && f2.isPrivate() && f2.isSynthetic() && !f2.getName().startsWith("this$")
                                    && f2.getName().contains("$")) {
                                continue writeOnlyFields;
                            }
                        }
                    }
                    JavaClass outerClass = Repository.lookupClass(outerClassName);
                    if (classHasParameter(outerClass)) {
                        continue;
                    }

                    ClassDescriptor cDesc = DescriptorFactory.createClassDescriptorFromDottedClassName(outerClassName);

                    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) {
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.