Package edu.umd.cs.findbugs.ba

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


    @Override
    public void sawOpcode(int seen) {

        if ((seen == INVOKESPECIAL) && getNameConstantOperand().equals("<init>") && getSigConstantOperand().equals("()V")) {
            XClass xClass = getXClassOperand();
            if (xClass == null) {
                return;
            }
            String clsName = getClassConstantOperand();
            if (clsName.equals("java/lang/Object")) {
View Full Code Here


        if (signature.charAt(0) == 'L') {
            ClassDescriptor fieldType = DescriptorFactory.createClassDescriptorFromFieldSignature(signature);

            while (fieldType != null) {
                XClass fieldClass;
                try {
                    fieldClass = Global.getAnalysisCache().getClassAnalysis(XClass.class, fieldType);
                } catch (CheckedAnalysisException e) {
                    break;
                }

                String name = fieldClass.getClassDescriptor().getClassName();
                if (name.startsWith("java/awt") || name.startsWith("javax/swing")) {
                    return;
                }
                if (name.equals("java/lang/Object")) {
                    break;
                }
                fieldType = fieldClass.getSuperclassDescriptor();
            }
        }

        // Get locations matching the beginning of the object creation,
        // and the final field store.
View Full Code Here

        while (d != null) {
            try {
                if ("java.lang.Exception".equals(d.getDottedClassName())) {
                    return true;
                }
                XClass classNameAndInfo = Global.getAnalysisCache().getClassAnalysis(XClass.class, d);
                d = classNameAndInfo.getSuperclassDescriptor();
            } catch (CheckedAnalysisException e) {
                return true; // don't know
            }
        }
        return false;
View Full Code Here

        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);
                                }
                            }
                        }
                    } catch (ClassNotFoundException e1) {
                        assert true;
                    }

                }

            }
            int overridden = 0, total = 0;
            for (Map.Entry<ClassDescriptor, Set<ClassDescriptor>> e : classesWithInstanceOfBasedEquals.entrySet()) {
                ClassAnnotation parentClass = ClassAnnotation.fromClassDescriptor(e.getKey());
                XClass xParent = AnalysisContext.currentXFactory().getXClass(e.getKey());
                if (xParent == null) {
                    continue;
                }
                EqualsKindSummary.KindOfEquals parentKind = equalsKindSummary.get(parentClass);
                boolean isOverridden = false;
                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);
View Full Code Here

        if (!enabled()) {
            return;
        }

        JavaClass jClass = classContext.getJavaClass();
        XClass xClass = classContext.getXClass();

        try {

            if (!isJunit3TestCase(xClass)) {
                return;
View Full Code Here

        if (sName.equals("java/lang/Object")) {
            return false;
        }

        try {
            XClass sClass = Global.getAnalysisCache().getClassAnalysis(XClass.class, sDesc);
            if (sClass == null) {
                return false;
            }
            return isJunit3TestCase(sClass);
        } catch (CheckedAnalysisException e) {
View Full Code Here

        }
        try {
            if (getSuperclassDescriptor() == null) {
                return null;
            }
            XClass superClass = Global.getAnalysisCache().getClassAnalysis(XClass.class, getSuperclassDescriptor());
            XField result = superClass.findField(name, signature, isStatic);
            if (result != null) {
                return result;
            }
            if (!isStatic) {
                return null;
            }
            ClassDescriptor[] interfaces = getInterfaceDescriptorList();
            for (ClassDescriptor implementedInterface : interfaces) {
                superClass = Global.getAnalysisCache().getClassAnalysis(XClass.class, implementedInterface);
                result = superClass.findField(name, signature, isStatic);
                if (result != null) {
                    return result;
                }
            }
            return null;
View Full Code Here

        LinkedList<XClass> workList = new LinkedList<XClass>();
        workList.add(xclass);

        while (!workList.isEmpty()) {
            XClass work = workList.removeFirst();
            ClassVertex vertex = classDescriptorToVertexMap.get(work.getClassDescriptor());
            if (vertex != null && vertex.isFinished()) {
                // This class has already been processed.
                continue;
            }

            if (vertex == null) {
                vertex = ClassVertex.createResolvedClassVertex(work.getClassDescriptor(), work);
                addVertexToGraph(work.getClassDescriptor(), vertex);
            }

            addSupertypeEdges(vertex, workList);

            vertex.setFinished(true);
View Full Code Here

        for (ClassDescriptor s : superDesc) {
            if (subDesc.equals(s)) {
                return true;
            }
        }
        XClass xclass = AnalysisContext.currentXFactory().getXClass(subDesc);
        if (xclass != null) {
            ClassDescriptor xSuper = xclass.getSuperclassDescriptor();
            for (ClassDescriptor s : superDesc) {
                if (s.equals(xSuper)) {
                    return true;
                }
            }
View Full Code Here

            return false;
        }

        //        if (true) {
        // XXX call below causes 88% of all MissingClassException thrown (20000 on java* JDK7 classes)
        XClass xclass = AnalysisContext.currentXFactory().getXClass(subDesc);
        if (xclass != null) {
            ClassDescriptor xSuper = xclass.getSuperclassDescriptor();
            if (superDesc.equals(xSuper)) {
                return true;
            }
            ClassDescriptor[] interfaces = xclass.getInterfaceDescriptorList();
            if (interfaces.length == 0) {
                if (xSuper == null) {
                    return false;
                }
                if (xSuper.getClassName().equals("java/lang/Object")) {
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.