Package edu.umd.cs.findbugs.ba

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


        if (seen == PUTFIELD && getClassConstantOperand().equals(getClassName())) {
            initializedFields.add(FieldAnnotation.fromReferencedField(this));
        } else if (thisOnTOS && seen == GETFIELD && getClassConstantOperand().equals(getClassName())) {
            UnreadFieldsData unreadFields = AnalysisContext.currentAnalysisContext().getUnreadFieldsData();
            XField xField = XFactory.createReferencedXField(this);
            FieldAnnotation f = FieldAnnotation.fromReferencedField(this);
            int nextOpcode = 0xff & codeBytes[getPC() + 3];
            if (nextOpcode != POP && !initializedFields.contains(f) && declaredFields.contains(f) && !containerFields.contains(f)
                    && !unreadFields.isContainerField(xField)) {
                // System.out.println("Next opcode: " +
                // OPCODE_NAMES[nextOpcode]);
                LocalVariableAnnotation possibleTarget = LocalVariableAnnotation.findMatchingIgnoredParameter(getClassContext(),
                        getMethod(), getNameConstantOperand(), xField.getSignature());
                if (possibleTarget == null) {
                    possibleTarget = LocalVariableAnnotation.findUniqueBestMatchingParameter(getClassContext(), getMethod(),
                            getNameConstantOperand(), getSigConstantOperand());
                }
                int priority = unreadFields.getReadFields().contains(xField) ? NORMAL_PRIORITY : LOW_PRIORITY;
View Full Code Here


    public void modelFieldLoad(FieldInstruction obj) {
        consumeStack(obj);

        Type loadType = obj.getFieldType(cpg);

        XField xfield = Hierarchy.findXField(obj, getCPG());
        if (xfield != null) {
            loadType = getType(xfield);
        }

View Full Code Here

        }

        if (seen == PUTFIELD) {
            OpcodeStack.Item obj = stack.getStackItem(1);
            OpcodeStack.Item value = stack.getStackItem(0);
            XField f = getXFieldOperand();
            XClass x = getXClassOperand();

            checkPUTFIELD: if (putFieldPC + 10 > getPC() && f != null && obj != null && f.equals(putFieldXField)
                    && !f.isSynthetic() && obj.equals(putFieldObj) && x != null) {

                LineNumberTable table = getCode().getLineNumberTable();
                if (table != null) {
                    int first = table.getSourceLine(putFieldPC);
                    int second = table.getSourceLine(getPC());
                    if (first + 1 != second && first != second) {
                        break checkPUTFIELD;
                    }
                } else if (putFieldPC + 3 != getPC()) {
                    break checkPUTFIELD;
                }

                int priority = NORMAL_PRIORITY;
                if (value.equals(putFieldValue) && putFieldPC + 3 != getPC()) {
                    priority++;
                }
                boolean storeOfDefaultValue = putFieldValue.isNull() || putFieldValue.hasConstantValue(0);
                if (storeOfDefaultValue) {
                    priority++;
                }
                if (f.isVolatile()) {
                    priority++;
                }
                XField intendedTarget = null;

                double minimumDistance = 2;
                int matches = 0;
                for (XField f2 : x.getXFields()) {
                    if (!f.equals(f2) && !f2.isStatic() && !f2.isFinal() && !f2.isSynthetic()
View Full Code Here

                        return;
                    }
                    linesDifference = (lastPos - firstPos)/10;
                }
            }
            XField field0 = item0.getXField();
            XField field1 = item1.getXField();
            int fr0 = item0.getFieldLoadedFromRegister();
            int fr1 = item1.getFieldLoadedFromRegister();
            if (field0 != null && field0.equals(field1) && (field0.isStatic() || fr0 != -1 && fr0 == fr1)) {
                int priority = NORMAL_PRIORITY;
                if (field0.isVolatile()) {
View Full Code Here

        if (!frame.isValid()) {
            return;
        }
        IsNullValue tos = frame.getTopValue();
        if (tos.isDefinitelyNull()) {
            XField field = XFactory.createXField(ins, cpg);
            NullnessAnnotation annotation = AnalysisContext.currentAnalysisContext().getNullnessAnnotationDatabase()
                    .getResolvedAnnotation(field, false);
            if (annotation == NullnessAnnotation.NONNULL) {

                BugAnnotation variableAnnotation = null;
View Full Code Here

                    bugType = "NP_TOSTRING_COULD_RETURN_NULL";
                    priority = NORMAL_PRIORITY;
                }

            } else {
                XField f = pu.getNonNullField();
                if (f != null) {
                    storedField = FieldAnnotation.fromXField(f);
                    bugType = "NP_STORE_INTO_NONNULL_FIELD";
                } else {
                    XMethodParameter mp = pu.getNonNullParameter();
View Full Code Here

            nullValueStored = getFrame().getTopValue();
        } catch (DataflowAnalysisException e1) {
            AnalysisContext.logError("Oops", e1);
        }
        super.visitPUTFIELD(obj);
        XField field = XFactory.createXField(obj, cpg);
        if (nullValueStored != null && ValueNumberAnalysisFeatures.REDUNDANT_LOAD_ELIMINATION) {
            try {
                ValueNumberFrame vnaFrameBefore = vnaDataflow.getFactAtLocation(getLocation());
                ValueNumber refValue = vnaFrameBefore.getStackValue(1);
                AvailableLoad load = new AvailableLoad(refValue, field);
View Full Code Here

        if (checkForKnownValue(obj)) {
            return;
        }

        XField field = XFactory.createXField(obj, cpg);

        NullnessAnnotation annotation = AnalysisContext.currentAnalysisContext().getNullnessAnnotationDatabase()
                .getResolvedAnnotation(field, false);
        if (annotation == NullnessAnnotation.NONNULL) {
            modelNormalInstruction(obj, getNumWordsConsumed(obj), 0);
View Full Code Here

        }

        if (checkForKnownValue(obj)) {
            return;
        }
        XField field = XFactory.createXField(obj, cpg);
        if (field.isFinal()) {
            Item summary = AnalysisContext.currentAnalysisContext().getFieldSummary().getSummary(field);
            if (summary.isNull()) {
                produce(IsNullValue.nullValue());
                return;
            }
        }
        if (field.getClassName().equals("java.util.logging.Level") && field.getName().equals("SEVERE")
                || field.getClassName().equals("org.apache.log4j.Level")
                && (field.getName().equals("ERROR") || field.getName().equals("FATAL"))) {
            getFrame().toExceptionValues();
        }

        if (field.getName().startsWith("class$")) {
            produce(IsNullValue.nonNullValue());
            return;
        }
        NullnessAnnotation annotation = AnalysisContext.currentAnalysisContext().getNullnessAnnotationDatabase()
                .getResolvedAnnotation(field, false);
View Full Code Here

     */
    @Override
    public void sawOpcode(int seen) {

        if (seen == GETSTATIC) {
            XField f = getXFieldOperand();
            if (pendingBugs.containsKey(f)) {
                if (!isLocked()) {
                    reporter.reportBug(pendingBugs.remove(f));

                }

            }
        }
        // we are only interested in method calls
        if (seen != INVOKEVIRTUAL) {
            return;
        }

        try {
            @SlashedClassName String className = getClassConstantOperand();

            if (className.startsWith("[")) {
                // Ignore array classes
                return;
            }
            ClassDescriptor cDesc = DescriptorFactory.createClassDescriptor(className);

            // if it is not compatible with Calendar or DateFormat, we are not
            // interested anymore
            boolean isCalendar = subtypes2.isSubtype(cDesc, calendarType);
            boolean isDateFormat = subtypes2.isSubtype(cDesc, dateFormatType);
            if (!isCalendar && !isDateFormat) {
                return;
            }

            // determine the number of arguments the method expects
            int numArguments = getNumberArguments(getSigConstantOperand());
            // go back on the stack to find what the receiver of the method is
            OpcodeStack.Item invokedOn = stack.getStackItem(numArguments);
            XField field = invokedOn.getXField();
            // find out, if the field is static. if not, we are not interested
            // anymore
            if (field == null || !field.isStatic()) {
                return;
            }

            if (getMethodName().equals("<clinit>") && field.getClassName().equals(getDottedClassName())) {
                return;
            }
            String invokedName = getNameConstantOperand();
            if (invokedName.startsWith("get")) {
                return;
            }
            if (invokedName.equals("equals") && numArguments == 1) {
                OpcodeStack.Item passedAsArgument = stack.getStackItem(0);
                field = passedAsArgument.getXField();
                if (field == null || !field.isStatic()) {
                    return;
                }
            }

            if (!SystemProperties.getBoolean(PROP_SKIP_SYNCHRONIZED_CHECK)) {
View Full Code Here

TOP

Related Classes of edu.umd.cs.findbugs.ba.XField

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.