Package edu.umd.cs.findbugs.ba

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


        if (DEBUG) {
            System.out.printf("Result for %s in %s%n", stream, methodGen);
            dataflow.dumpDataflow(dataflow.getAnalysis());

        }
        ResourceValueFrame exitFrame = dataflow.getResultFact(cfg.getExit());

        int exitStatus = exitFrame.getStatus();
        if (exitStatus == ResourceValueFrame.OPEN || exitStatus == ResourceValueFrame.OPEN_ON_EXCEPTION_PATH) {

            // FIXME: Stream object should be queried for the
            // priority.
View Full Code Here


    public void inspectResult(ClassContext classContext, MethodGen methodGen, CFG cfg,
            Dataflow<ResourceValueFrame, ResourceValueAnalysis<Lock>> dataflow, Lock resource) {

        JavaClass javaClass = classContext.getJavaClass();

        ResourceValueFrame exitFrame = dataflow.getResultFact(cfg.getExit());
        if (DEBUG) {
            System.out.println("Resource value at exit: " + exitFrame);
        }
        int exitStatus = exitFrame.getStatus();

        if (exitStatus == ResourceValueFrame.OPEN || exitStatus == ResourceValueFrame.OPEN_ON_EXCEPTION_PATH) {
            String bugType;
            int priority;
            if (exitStatus == ResourceValueFrame.OPEN) {
View Full Code Here

        @Override
        public void transferInstruction(InstructionHandle handle, BasicBlock basicBlock) throws DataflowAnalysisException {
            final Instruction ins = handle.getInstruction();
            final ConstantPoolGen cpg = getCPG();
            final ResourceValueFrame frame = getFrame();

            int status = -1;

            if (DEBUG) {
                System.out.println("PC : " + handle.getPosition() + " " + ins);
            }
            if (DEBUG && ins instanceof InvokeInstruction) {
                InvokeInstruction iins = (InvokeInstruction) ins;
                System.out.println("  " + ins.toString(cpg.getConstantPool()));
            }
            if (DEBUG) {
                System.out.println("resource frame before instruction: " + frame.toString());
            }

            // Is a lock acquired or released by this instruction?
            Location creationPoint = lock.getLocation();
            if (handle == creationPoint.getHandle() && basicBlock == creationPoint.getBasicBlock()) {
                status = ResourceValueFrame.OPEN;
                if (DEBUG) {
                    System.out.println("OPEN");
                }
            } else if (resourceTracker.isResourceClose(basicBlock, handle, cpg, lock, frame)) {
                status = ResourceValueFrame.CLOSED;
                if (DEBUG) {
                    System.out.println("CLOSE");
                }
            }

            // Model use of instance values in frame slots
            analyzeInstruction(ins);

            final int updatedNumSlots = frame.getNumSlots();

            // Mark any appearances of the lock value in the ResourceValueFrame.
            ValueNumberFrame vnaFrame = vnaDataflow.getFactAfterLocation(new Location(handle, basicBlock));
            if (DEBUG) {
                System.out.println("vna frame after instruction: " + vnaFrame.toString());
                System.out.println("Lock value number: " + lock.getLockValue());
                if (lock.getLockValue().hasFlag(ValueNumber.RETURN_VALUE)) {
                    System.out.println("is return value");
                }
            }

            for (int i = 0; i < updatedNumSlots; ++i) {
                if (DEBUG) {
                    System.out.println("Slot " + i);
                    System.out.println("  Lock value number: " + vnaFrame.getValue(i));
                    if (vnaFrame.getValue(i).hasFlag(ValueNumber.RETURN_VALUE)) {
                        System.out.println("  is return value");
                    }
                }
                if (vnaFrame.fuzzyMatch(lock.getLockValue(), vnaFrame.getValue(i))) {
                    if (DEBUG) {
                        System.out.println("Saw lock value!");
                    }
                    frame.setValue(i, ResourceValue.instance());
                }
            }

            // If needed, update frame status
            if (status != -1) {
                frame.setStatus(status);
            }
            if (DEBUG) {
                System.out.println("resource frame after instruction: " + frame.toString());
            }

        }
View Full Code Here

    public void transferInstruction(InstructionHandle handle, BasicBlock basicBlock) throws DataflowAnalysisException {
        // Record what Location we are analyzing
        this.location = new Location(handle, basicBlock);

        final Instruction ins = handle.getInstruction();
        final ResourceValueFrame frame = getFrame();

        int status = -1;
        boolean created = false;

        // Is a resource created, opened, or closed by this instruction?
        Location creationPoint = stream.getLocation();
        if (handle == creationPoint.getHandle() && basicBlock == creationPoint.getBasicBlock()) {
            // Resource creation
            if (stream.isOpenOnCreation()) {
                status = ResourceValueFrame.OPEN;
                stream.setOpenLocation(location);
                resourceTracker.addStreamOpenLocation(location, stream);
            } else {
                status = ResourceValueFrame.CREATED;
            }
            created = true;
        } else if (resourceTracker.isResourceOpen(basicBlock, handle, cpg, stream, frame)) {
            // Resource opened
            status = ResourceValueFrame.OPEN;
            stream.setOpenLocation(location);
            resourceTracker.addStreamOpenLocation(location, stream);
        } else if (resourceTracker.isResourceClose(basicBlock, handle, cpg, stream, frame)) {
            // Resource closed
            status = ResourceValueFrame.CLOSED;
        }

        // Model use of instance values in frame slots
        analyzeInstruction(ins);

        // If needed, update frame status
        if (status != -1) {
            frame.setStatus(status);
            if (created) {
                frame.setValue(frame.getNumSlots() - 1, ResourceValue.instance());
            }
        }

    }
View Full Code Here

TOP

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

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.