Package edu.umd.cs.findbugs.ba

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


        superClassHasReadObject = false;
        superClassImplementsSerializable = isSerializable && !implementsSerializableDirectly;
        ClassDescriptor superclassDescriptor = getXClass().getSuperclassDescriptor();
        if (superclassDescriptor != null) {
            try {
                XClass superXClass = Global.getAnalysisCache().getClassAnalysis(XClass.class, superclassDescriptor);
                if (superXClass != null) {
                    superClassImplementsSerializable = AnalysisContext
                            .currentAnalysisContext()
                            .getSubtypes2()
                            .isSubtype(superXClass.getClassDescriptor(),
                                    DescriptorFactory.createClassDescriptor(java.io.Serializable.class));
                    superClassHasVoidConstructor = false;
                    for (XMethod m : superXClass.getXMethods()) {
                        if (m.getName().equals("<init>") && m.getSignature().equals("()V") && !m.isPrivate()) {
                            superClassHasVoidConstructor = true;
                        }
                        if (m.getName().equals("readObject") && m.getSignature().equals("(Ljava/io/ObjectInputStream;)V")
                                && m.isPrivate()) {
View Full Code Here


                        .addClassAndMethod(this);
                        boolean nasty = false;
                        for (ClassDescriptor subclass : subtypes) {
                            if (!subclass.equals(getClassDescriptor())) {

                                XClass xSub = AnalysisContext.currentXFactory().getXClass(subclass);
                                if (xSub != null && xSub.findMethod("readResolve", "()Ljava/lang/Object;", false) == null
                                        && xSub.findMethod("writeReplace", "()Ljava/lang/Object;", false) == null) {
                                    bug.addClass(subclass).describe(ClassAnnotation.SUBCLASS_ROLE);
                                    nasty = true;
                                }
                            }
                        }
View Full Code Here

        }
        if (dottedClassName.startsWith("java.util.") || dottedClassName.startsWith("com.google.common.collect.") ) {
            return true;
        }
        try {
            XClass xclass = Global.getAnalysisCache().getClassAnalysis(XClass.class, operandClass);

            String sig = xclass.getSourceSignature();
            if (sig == null) {
                return false;
            }

            String typeParameter = null;
View Full Code Here

            }

        }

        XClass xclass = Global.getAnalysisCache().getClassAnalysis(XClass.class, classDescriptor);
        List<? extends XMethod> methods = xclass.getXMethods();
        if (DEBUG) {
            System.out.println("CEW: checking " + xclass.toString());
        }
        check(xclass, expectWarning, true, HIGH_PRIORITY);
        check(xclass, desireWarning, true, NORMAL_PRIORITY);
        check(xclass, noWarning, false, HIGH_PRIORITY);
        check(xclass, desireNoWarning, false, NORMAL_PRIORITY);

        for (XMethod xmethod : methods) {
            if (DEBUG) {
                System.out.println("CEW: checking " + xmethod.toString());
            }
            check(xmethod, expectWarning, true, HIGH_PRIORITY);
            check(xmethod, desireWarning, true, NORMAL_PRIORITY);
            check(xmethod, noWarning, false, HIGH_PRIORITY);
            check(xmethod, desireNoWarning, false, NORMAL_PRIORITY);
        }
        for (XField xfield : xclass.getXFields()) {
            if (DEBUG) {
                System.out.println("CEW: checking " + xfield.toString());
            }
            check(xfield, expectWarning, true, HIGH_PRIORITY);
            check(xfield, desireWarning, true, NORMAL_PRIORITY);
View Full Code Here

    public void visit(Code obj) {
        sawInitializeSuper = false;
        super.visit(obj);
        fieldSummary.setFieldsWritten(getXMethod(), touched);
        if (getMethodName().equals("<init>") && sawInitializeSuper) {
            XClass thisClass = getXClass();
            for (XField f : thisClass.getXFields()) {
                if (!f.isStatic() && !f.isFinal() && !touched.contains(f)) {
                    OpcodeStack.Item item;
                    char firstChar = f.getSignature().charAt(0);
                    if (firstChar == 'L' || firstChar == '[') {
                        item = OpcodeStack.Item.nullItem(f.getSignature());
View Full Code Here

            int priority = targets.size() == 1 ? Priorities.HIGH_PRIORITY : Priorities.NORMAL_PRIORITY;
            for (XMethod m : targets) {
                if (!m.isUnsupported()) {
                    continue locationLoop;
                }
                XClass xc = AnalysisContext.currentXFactory().getXClass(m.getClassDescriptor());
                if (!(inv instanceof INVOKESTATIC) && !(m.isFinal() || xc.isFinal())) {
                    priority = Priorities.NORMAL_PRIORITY;
                }
                if (xc == null || xc.isAbstract()) {
                    try {
                        if (!AnalysisContext.currentAnalysisContext().getSubtypes2().hasSubtypes(m.getClassDescriptor())) {
                            continue locationLoop;
                        }
                    } catch (ClassNotFoundException e) {
View Full Code Here

            }
        }

        // Walk up the super class chain, looking for name collisions

        XClass c = getXClass();
        while (true) {
            ClassDescriptor s = c.getSuperclassDescriptor();
            if (s == null || s.getClassName().equals("java/lang/Object")) {
                break;
            }
            try {
                c = Global.getAnalysisCache().getClassAnalysis(XClass.class, s);
            } catch (CheckedAnalysisException e) {
                break;
            }
            XClass superClass = c;
            for (XField fld : c.getXFields()) {
                if (!fld.isStatic() && (fld.isPublic() || fld.isProtected())) {
                    fieldName = fld.getName();
                    if (fieldName.length() == 1) {
                        continue;
View Full Code Here

            String className = cd.getClassName();
            if (immutableClassNames.contains(className)) {
                return Priorities.LOW_PRIORITY;
            }

            XClass xClass = AnalysisContext.currentXFactory().getXClass(cd);
            if (xClass == null) {
                return Priorities.IGNORE_PRIORITY;
            }
            ClassDescriptor superclassDescriptor = xClass.getSuperclassDescriptor();
            if (superclassDescriptor != null) {
                @SlashedClassName
                String superClassName = superclassDescriptor.getClassName();
                if (superClassName.equals("java/lang/Enum")) {
                    return Priorities.LOW_PRIORITY;
                }
            }
            boolean hasMutableField = false;
            boolean hasUpdates = false;
            for (XField f : xClass.getXFields()) {
                if (!f.isStatic()) {
                    if (!f.isFinal() && !f.isSynthetic()) {
                        hasMutableField = true;
                        if (unreadFields.isWrittenOutsideOfInitialization(f)) {
                            hasUpdates = true;
                        }
                    }
                    String signature = f.getSignature();
                    if (signature.startsWith("Ljava/util/concurrent") || signature.startsWith("Ljava/lang/StringB")
                            || signature.charAt(0) == '[' || signature.indexOf("Map") >= 0 || signature.indexOf("List") >= 0
                            || signature.indexOf("Set") >= 0) {
                        hasMutableField = hasUpdates = true;
                    }

                }
            }

            if (!hasMutableField && !xClass.isInterface() && !xClass.isAbstract()) {
                return Priorities.LOW_PRIORITY;
            }
            if (hasUpdates || className.startsWith("java/util") || className.indexOf("Map") >= 0
                    || className.indexOf("List") >= 0) {
                return Priorities.HIGH_PRIORITY;
View Full Code Here

                        if (methodName.equals("<init>") || methodName.startsWith("set") && getCode().getCode().length <= 5
                                || !previousStores.get(getRegisterOperand())) {
                            priority = HIGH_PRIORITY;
                        }
                        previousStores.set(getRegisterOperand());
                        XClass c = getXClass();
                        LocalVariableAnnotation local = LocalVariableAnnotation.getLocalVariableAnnotation(getMethod(),
                                getRegisterOperand(), getPC(), getPC());
                        if (local.getName().equals("?")) {
                            priority++;
                        } else {
                            for (XField f : c.getXFields()) {
                                if (f.getName().equals(local.getName()) && (f.isStatic() || !getMethod().isStatic())) {
                                    bugReporter.reportBug(new BugInstance(this, "SA_LOCAL_SELF_ASSIGNMENT_INSTEAD_OF_FIELD",
                                            priority).addClassAndMethod(this).add(local).addField(f)
                                            .describe(FieldAnnotation.DID_YOU_MEAN_ROLE).addSourceLine(this));
                                    return;
View Full Code Here

            //            boolean isPublic = f.isPublic();
            boolean couldBePackage = !outsidePackage.contains(f);
            boolean movedOutofInterface = false;

            try {
                XClass xClass = Global.getAnalysisCache().getClassAnalysis(XClass.class, f.getClassDescriptor());
                movedOutofInterface = couldBePackage && xClass.isInterface();
            } catch (CheckedAnalysisException e) {
                assert true;
            }
            boolean isHashtable = fieldSig.equals("Ljava/util/Hashtable;");
            boolean isArray = fieldSig.charAt(0) == '[' && unsafeValue.contains(f);
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.