Package edu.umd.cs.findbugs.ba.jsr305

Examples of edu.umd.cs.findbugs.ba.jsr305.TypeQualifierResolver


            nullArgSet = (BitSet) nullArgSet.clone();
            definitelyNullArgSet = (BitSet) definitelyNullArgSet.clone();
            ClassDescriptor nonnullClassDesc = DescriptorFactory.createClassDescriptor(javax.annotation.Nonnull.class);
            TypeQualifierValue<?> nonnullTypeQualifierValue = TypeQualifierValue.getValue(nonnullClassDesc, null);
            for (int i = nullArgSet.nextSetBit(0); i >= 0; i = nullArgSet.nextSetBit(i + 1)) {
                TypeQualifierAnnotation tqa = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation(calledMethod, i,
                        nonnullTypeQualifierValue);
                if (tqa != null && tqa.when == When.ALWAYS) {
                    nullArgSet.clear(i);
                    definitelyNullArgSet.clear(i);
                }
View Full Code Here


            if (DEBUG) {
                System.out.println("getResolvedAnnotation: o=" + o + "...");
            }

            TypeQualifierAnnotation tqa = null;

            if (o instanceof XMethodParameter) {
                XMethodParameter param = (XMethodParameter) o;

                tqa = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation(param.getMethod(),
View Full Code Here

    public @CheckForNull NullnessAnnotation getInheritedAnnotation(XMethod m, int parameter) {
        Profiler profiler = Global.getAnalysisCache().getProfiler();
        profiler.start(this.getClass());
        try {
            TypeQualifierAnnotation tqa
            = TypeQualifierApplications.getInheritedTypeQualifierAnnotation(m,
                    parameter, nonnullTypeQualifierValue);
            NullnessAnnotation result = toNullnessAnnotation(tqa);
            return result;
        } finally {
View Full Code Here

    }
    public @CheckForNull NullnessAnnotation getInheritedAnnotation(XMethod m) {
        Profiler profiler = Global.getAnalysisCache().getProfiler();
        profiler.start(this.getClass());
        try {
            TypeQualifierAnnotation tqa
            = TypeQualifierApplications.getInheritedTypeQualifierAnnotation(m, nonnullTypeQualifierValue);
            NullnessAnnotation result = toNullnessAnnotation(tqa);
            return result;
        } finally {
            profiler.end(this.getClass());
View Full Code Here

            if (DEBUG) {
                System.out.println("getDirectAnnotation: o=" + o + "...");
            }

            TypeQualifierAnnotation tqa = null;

            if (o instanceof XMethodParameter) {
                XMethodParameter param = (XMethodParameter) o;
                tqa = TypeQualifierApplications.getDirectTypeQualifierAnnotation(param.getMethod(),
                        param.getParameterNumber(), nonnullTypeQualifierValue);
View Full Code Here

    @Override
    public boolean parameterMustBeNonNull(XMethod m, int param) {
        if (DEBUG) {
            System.out.print("Checking " + m + " param " + param + " for @Nonnull...");
        }
        TypeQualifierAnnotation tqa = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation(m, param,
                nonnullTypeQualifierValue);

        if (tqa == null && param == 0) {
            String name = m.getName();
            String signature = m.getSignature();
View Full Code Here

                    emitSourceWarning(bugType, xMethod, typeQualifierValue, backwardsFlowValue, backwardsFact, source,
                            vn, location);
                } else if (source.getWhen() == When.UNKNOWN && source.getType() == SourceSinkType.PARAMETER) {

                    int p = source.getParameter();
                    TypeQualifierAnnotation directTypeQualifierAnnotation = TypeQualifierApplications
                            .getDirectTypeQualifierAnnotation(xMethod, p, typeQualifierValue);
                    if (directTypeQualifierAnnotation != null && directTypeQualifierAnnotation.when == When.UNKNOWN) {
                        String bugType = (backwardsFlowValue == FlowValue.NEVER) ? "TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_NEVER_SINK"
                                : "TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_ALWAYS_SINK";
View Full Code Here

                String paramSig = paramIterator.next();

                ValueNumber paramVN = vnaDataflow.getAnalysis().getEntryValue(paramLocalOffset);

                handleParameter: if (entryFact.isUnconditionallyDereferenced(paramVN)) {
                    TypeQualifierAnnotation directTypeQualifierAnnotation = TypeQualifierApplications
                            .getDirectTypeQualifierAnnotation(xmethod, i, nonnullTypeQualifierValue);
                    TypeQualifierAnnotation typeQualifierAnnotation = TypeQualifierApplications
                            .getEffectiveTypeQualifierAnnotation(xmethod, i, nonnullTypeQualifierValue);
                    boolean implicitNullCheckForEquals = false;
                    if (directTypeQualifierAnnotation == null && method.getName().equals("equals")
                            && method.getSignature().equals("(Ljava/lang/Object;)Z") && !method.isStatic()) {
                        implicitNullCheckForEquals = true;
View Full Code Here

            ValueNumberDataflow vnaDataflow, ForwardTypeQualifierDataflow forwardDataflow,
            BackwardTypeQualifierDataflow backwardDataflow) throws DataflowAnalysisException, CheckedAnalysisException {
        for (Iterator<Location> i = cfg.locationIterator(); i.hasNext();) {
            Location loc = i.next();

            TypeQualifierValueSet forwardsFact = forwardDataflow.getFactAtLocation(loc);
            TypeQualifierValueSet backwardsFact = backwardDataflow.getFactAfterLocation(loc);

            if (!forwardsFact.isValid() || !backwardsFact.isValid()) {
                continue;
            }

            if (DEBUG) {
                checkLocation = "location " + loc.toCompactString();
            }
            checkForConflictingValues(xmethod, cfg, typeQualifierValue, forwardsFact, backwardsFact, loc,
                    loc, vnaDataflow.getFactAtLocation(loc));
            checkForEqualityTest(xmethod, cfg, typeQualifierValue, forwardsFact, loc, vnaDataflow.getFactAtLocation(loc));
        }

        for (Iterator<Edge> i = cfg.edgeIterator(); i.hasNext();) {
            Edge edge = i.next();


            // NOTE: when checking forwards and backwards values on an edge,
            // we don't want to apply BOTH edge transfer functions,
            // since the purpose of the edge transfer function is to
            // propagate information across phi nodes (effectively
            // copying information about one value to another).
            // Due to pruning of backwards values when a conflict is detected,
            // we need to check backwards values as "early" as possible,
            // meaning that we want to check at the edge target
            // (before the backwards edge transfer function has pruned
            // the backwards value.)
            TypeQualifierValueSet forwardFact = forwardDataflow.getFactOnEdge(edge);
            TypeQualifierValueSet backwardFact = backwardDataflow.getResultFact(edge.getTarget());

            // The edge target location is where we can check
            // for conflicting flow values.
            Location edgeTargetLocation = getEdgeTargetLocation(cfg, edge);
            ValueNumberFrame vnaFrame = (edgeTargetLocation != null) ? vnaDataflow.getFactAtLocation(edgeTargetLocation) : null;
View Full Code Here

            Set<SourceSinkInfo> sourceSet = forwardDataflow.getAnalysis().getSourceSinkInfoSet(location);

            for (SourceSinkInfo source : sourceSet) {
                ValueNumber vn = source.getValueNumber();
                TypeQualifierValueSet backwardsFact = backwardDataflow.getFactAtLocation(location);
                FlowValue backwardsFlowValue = backwardsFact.getValue(vn);

                if (!(backwardsFlowValue == FlowValue.ALWAYS || backwardsFlowValue == FlowValue.NEVER)) {
                    continue;
                }
                if (DEBUG) {
                    System.out.println("Checking value source at " + location.toCompactString() + " for " + typeQualifierValue);
                    System.out.println("  back=" + backwardsFact);
                    System.out.println("  source=" + source);
                }

                // Check to see if this warning has already been reported
                // because
                // the dataflow values conflict directly with each other.
                TypeQualifierValueSet forwardsFact = forwardDataflow.getFactAfterLocation(location);
                FlowValue forwardsFlowValue = forwardsFact.getValue(vn);
                if (FlowValue.valuesConflict(typeQualifierValue.isStrictQualifier() && !xMethod.isIdentity(), forwardsFlowValue, backwardsFlowValue)) {
                    continue;
                }

                if (FlowValue.backwardsValueConflictsWithSource(backwardsFlowValue, source, typeQualifierValue, xMethod.isIdentity())) {
View Full Code Here

TOP

Related Classes of edu.umd.cs.findbugs.ba.jsr305.TypeQualifierResolver

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.