Package edu.umd.cs.findbugs.ba.obl

Examples of edu.umd.cs.findbugs.ba.obl.State


            // see if there are any states with nonempty obligation sets.
            //
            Map<Obligation, State> leakedObligationMap = new HashMap<Obligation, State>();
            StateSet factAtExit = dataflow.getResultFact(cfg.getExit());
            for (Iterator<State> i = factAtExit.stateIterator(); i.hasNext();) {
                State state = i.next();
                checkStateForLeakedObligations(state, leakedObligationMap);
            }

            //
            // Report a separate BugInstance for each Obligation,State pair.
            // (Two different obligations may be leaked in the same state.)
            //
            for (Map.Entry<Obligation, State> entry : leakedObligationMap.entrySet()) {
                Obligation obligation = entry.getKey();
                State state = entry.getValue();
                reportWarning(obligation, state, factAtExit);
            }
            // TODO: closing of nonexistent resources

        }
View Full Code Here


                        // Get the entry fact - it should have precisely one
                        // state
                        StateSet entryFact = dataflow.getResultFact(curBlock);
                        Iterator<State> i = entryFact.stateIterator();
                        if (i.hasNext()) {
                            State entryState = i.next();
                            if (entryState.getObligationSet().getCount(obligation.getId()) > 0) {
                                lastSourceLine = SourceLineAnnotation.forFirstLineOfMethod(methodDescriptor);
                                lastSourceLine
                                .setDescription(SourceLineAnnotation.ROLE_OBLIGATION_CREATED_BY_WILLCLOSE_PARAMETER);
                                bugInstance.add(lastSourceLine);
                                sawFirstCreation = true;
View Full Code Here

                    System.out.println("Checking " + handle + " as possible obligation transfer...:");
                }

                // Find the State which is a prefix of the error state
                // at the location of this (possible) transfer.
                State transferState = getTransferState(handle);
                if (transferState == null) {
                    if (DEBUG_FP) {
                        System.out.println("No transfer state???");
                    }
                    return;
                }

                String methodName = inv.getMethodName(cpg);
                Type producedType = methodName.equals("<init>") ? inv.getReferenceType(cpg) : inv.getReturnType(cpg);

                if (DEBUG_FP && !(producedType instanceof ObjectType)) {
                    System.out.println("Produced type " + producedType + " not an ObjectType");
                }

                if (producedType instanceof ObjectType) {
                    Obligation produced = database.getFactory().getObligationByType((ObjectType) producedType);

                    if (DEBUG_FP && produced == null) {
                        System.out.println("Produced type  " + producedType + " not an obligation type");
                    }

                    if (produced != null) {
                        XMethod calledMethod = XFactory.createXMethod(inv, cpg);
                        Obligation[] params = database.getFactory().getParameterObligationTypes(calledMethod);

                        for (int i = 0; i < params.length; i++) {
                            Obligation consumed = params[i];

                            if (DEBUG_FP && consumed == null) {
                                System.out.println("Param " + i + " not an obligation type");
                            }

                            if (DEBUG_FP && consumed != null && consumed.equals(produced)) {
                                System.out.println("Consumed type is the same as produced type");
                            }

                            if (consumed != null && !consumed.equals(produced)) {
                                // See if an instance of the consumed obligation
                                // type
                                // exists here.
                                if (transferState.getObligationSet().getCount(consumed.getId()) > 0) {
                                    transferList.add(new PossibleObligationTransfer(consumed, produced));
                                    if (DEBUG_FP) {
                                        System.out.println("===> Possible transfer of " + consumed + " to " + produced + " at "
                                                + handle);
                                    }
                                } else if (DEBUG_FP) {
                                    System.out.println(handle + " not a transfer " + "of " + consumed + "->" + produced
                                            + " because no instances of " + consumed);
                                    System.out.println("I see " + transferState.getObligationSet());
                                }
                            }
                        }
                    }
                }
View Full Code Here

TOP

Related Classes of edu.umd.cs.findbugs.ba.obl.State

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.