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

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


     * throws
     * ClassNotFoundException
     */{
        try {

            Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2();
            return subtypes2.isSubtype(ref, Type.THROWABLE);

        } catch (ClassNotFoundException e) {
            // We'll just assume that it's not an exception type.
            lookupFailureCallback.reportMissingClass(e);
            return false;
View Full Code Here


    private void compute() {
        if (defined == null) {
            // System.out.println("Computing");
            defined = new HashSet<String>();

            Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2();
            Collection<XClass> allClasses = subtypes2.getXClassCollection();

            IAnalysisCache analysisCache = Global.getAnalysisCache();

            for (XClass c : allClasses) {
                try {
View Full Code Here

                    if (getPC() + 4 >= getCode().getCode().length) {
                        priority = Priorities.LOW_PRIORITY;
                    }
                    BugInstance bug = new BugInstance(this, "SC_START_IN_CTOR", priority).addClassAndMethod(this)
                            .addCalledMethod(this);
                    Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2();
                    Set<ClassDescriptor> directSubtypes = subtypes2.getDirectSubtypes(getClassDescriptor());
                    if (!directSubtypes.isEmpty()) {
                        for (ClassDescriptor sub : directSubtypes) {
                            bug.addClass(sub).describe(ClassAnnotation.SUBCLASS_ROLE);
                        }
                        bug.setPriority(Priorities.HIGH_PRIORITY);
View Full Code Here

     * @return adjusted priority
     */
    private int adjustPriority(int priority) {

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

            if (!subtypes2.hasSubtypes(getClassDescriptor())) {
                priority++;
            } else {
                Set<ClassDescriptor> mySubtypes = subtypes2.getSubtypes(getClassDescriptor());

                String myPackagename = getThisClass().getPackageName();

                for (ClassDescriptor c : mySubtypes) {
                    if (c.equals(getClassDescriptor())) {
View Full Code Here

    @Override
    public void visit(JavaClass obj) {
        isTigerOrHigher = obj.getMajor() >= MAJOR_1_5;
        try {
            Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2();
            ClassDescriptor me = getClassDescriptor();
            if (subtypes2.isSubtype(me, MAP_ENTRY) && subtypes2.isSubtype(me, ITERATOR)) {
                bugReporter.reportBug(new BugInstance(this, "PZ_DONT_REUSE_ENTRY_OBJECTS_IN_ITERATORS", NORMAL_PRIORITY)
                .addClass(this).addString("shouldn't reuse Iterator as a Map.Entry"));
            }
        } catch (ClassNotFoundException e) {
            AnalysisContext.reportMissingClass(e);
View Full Code Here

        this.bugReporter = bugReporter;
    }

    @Override
    public void visitClassContext(ClassContext classContext) {
        Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2();
        try {
            if (subtypes2.isSubtype(classContext.getClassDescriptor(), iteratorDescriptor)) {
                super.visitClassContext(classContext);
            }
        } catch (ClassNotFoundException e) {
            bugReporter.reportMissingClass(e);
        }
View Full Code Here

                                BugInstance bug = new BugInstance(this, "EQ_GETCLASS_AND_CLASS_CONSTANT", priority)
                                .addClassAndMethod(this);

                                try {

                                    Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2();
                                    Set<ClassDescriptor> subtypes = subtypes2.getDirectSubtypes(getClassDescriptor());
                                    for (ClassDescriptor c : subtypes) {
                                        try {
                                            Global.getAnalysisCache().getClassAnalysis(XClass.class, c);
                                        } catch (CheckedAnalysisException e) {
                                            continue;
View Full Code Here

    @Override
    public void report() {

        if (false) {
            Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2();
            for (Map.Entry<ClassDescriptor, Set<ClassDescriptor>> e : classesWithGetClassBasedEquals.entrySet()) {
                ClassAnnotation parentClass = ClassAnnotation.fromClassDescriptor(e.getKey());
                XClass xParent = AnalysisContext.currentXFactory().getXClass(e.getKey());
                if (xParent == null) {
                    continue;
                }
                EqualsKindSummary.KindOfEquals parentKind = equalsKindSummary.get(parentClass);
                for (ClassDescriptor child : e.getValue()) {
                    if (child.equals(e.getKey())) {
                        continue;
                    }
                    XClass xChild = AnalysisContext.currentXFactory().getXClass(child);
                    if (xChild == null) {
                        continue;
                    }
                    ClassAnnotation childClass = ClassAnnotation.fromClassDescriptor(child);
                    EqualsKindSummary.KindOfEquals childKind = equalsKindSummary.get(childClass);
                    int fieldsOfInterest = 0;
                    for (XField f : xChild.getXFields()) {
                        if (!f.isStatic() && !f.isSynthetic()) {
                            fieldsOfInterest++;
                        }
                    }
                    int grandchildren = -1;
                    try {

                        grandchildren = subtypes2.getSubtypes(child).size();
                    } catch (ClassNotFoundException e1) {
                        assert true;
                    }
                    System.out.println(parentKind + " " + childKind + " " + parentClass + " " + childClass + " "
                            + fieldsOfInterest + " " + grandchildren);
                    try {
                        if (grandchildren >= 2) {
                            for (ClassDescriptor g : subtypes2.getSubtypes(child)) {
                                if (!g.equals(child)) {
                                    System.out.println("  " + g);
                                }
                            }
                        }
View Full Code Here

     *            the name of the possible superclass
     * @return true if clsName is a subtype of possibleSupertypeClassName, false
     *         if not
     */
    public static boolean isSubtype(@DottedClassName String clsName, @DottedClassName String possibleSupertypeClassName) throws ClassNotFoundException {
        Subtypes2 subtypes2 = Global.getAnalysisCache().getDatabase(Subtypes2.class);
        return subtypes2.isSubtype(DescriptorFactory.createClassDescriptorFromDottedClassName(clsName), DescriptorFactory.createClassDescriptorFromDottedClassName(possibleSupertypeClassName));
    }
View Full Code Here

    public static boolean isUncheckedException(ObjectType type) throws ClassNotFoundException {
        if (type.equals(Type.THROWABLE) || type.equals(RUNTIME_EXCEPTION_TYPE) || type.equals(ERROR_TYPE)) {
            return true;
        }
        ClassDescriptor c = DescriptorFactory.getClassDescriptor(type);
        Subtypes2 subtypes2 = Global.getAnalysisCache().getDatabase(Subtypes2.class);
        return subtypes2.isSubtype(c, RUNTIME_EXCEPTION, ERROR);

    }
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.