Package edu.umd.cs.findbugs.ba

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


            }

            private State getTransferState(InstructionHandle handle) {
                StateSet stateSet;
                try {
                    stateSet = dataflow.getFactAtLocation(new Location(handle, curBlock));
                } catch (DataflowAnalysisException e) {
                    bugReporter.logError("Error checking obligation state at " + handle, e);
                    return null;
                }
View Full Code Here


            System.out.println("\n" + fullMethodName);
        }

        // Process each instruction
        for (Iterator<Location> iter = cfg.locationIterator(); iter.hasNext();) {
            Location location = iter.next();
            InstructionHandle handle = location.getHandle();
            Instruction ins = handle.getInstruction();

            // Only consider invoke instructions
            if (!(ins instanceof InvokeInstruction)) {
                continue;
View Full Code Here

                bugType = "UL_UNRELEASED_LOCK_EXCEPTION_PATH";
                priority = NORMAL_PRIORITY;
            }

            String sourceFile = javaClass.getSourceFileName();
            Location location = resource.getLocation();
            InstructionHandle handle = location.getHandle();
            InstructionHandle nextInstruction = handle.getNext();
            if (nextInstruction.getInstruction() instanceof RETURN)
            {
                return; // don't report as error; intentional
            }
View Full Code Here

            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");
View Full Code Here

            try {
                if (methodName.equals("lock") && methodSig.equals("()V")
                        && Hierarchy.isSubtype(className, "java.util.concurrent.locks.Lock")) {

                    Location location = new Location(handle, basicBlock);
                    ValueNumberFrame frame = vnaDataflow.getFactAtLocation(location);
                    ValueNumber lockValue = frame.getTopValue();
                    if (DEBUG) {
                        System.out.println("Lock value is " + lockValue.getNumber() + ", frame=" + frame.toString());
                    }
View Full Code Here

        @Override
        public boolean ignoreExceptionEdge(Edge edge, Lock resource, ConstantPoolGen cpg) {

            try {
                Location location = cfg.getExceptionThrowerLocation(edge);
                if (DEBUG) {
                    System.out.println("Exception thrower location: " + location);
                }
                Instruction ins = location.getHandle().getInstruction();

                if (ins instanceof GETFIELD) {
                    GETFIELD insGetfield = (GETFIELD) ins;
                    String fieldName = insGetfield.getFieldName(cpg);
                    if (DEBUG) {
View Full Code Here

        // Use precomputed map of Locations to Stream creations,
        // if present. Note that we don't care about preexisting
        // resources here.
        if (resourceCollection != null) {
            return resourceCollection.getCreatedResource(new Location(handle, basicBlock));
        }

        Instruction ins = handle.getInstruction();
        if (!(ins instanceof TypedInstruction)) {
            return null;
        }

        Type type = ((TypedInstruction) ins).getType(cpg);
        if (!(type instanceof ObjectType)) {
            return null;
        }

        Location location = new Location(handle, basicBlock);

        // All StreamFactories are given an opportunity to
        // look at the location and possibly identify a created stream.
        for (StreamFactory aStreamFactoryList : streamFactoryList) {
            Stream stream = aStreamFactoryList.createStream(location, (ObjectType) type, cpg, lookupFailureCallback);
View Full Code Here

        CFG cfg = classContext.getCFG(method);
        TypeDataflow typeDataflow = classContext.getTypeDataflow(method);
        ConstantPoolGen constantPoolGen = classContext.getConstantPoolGen();

        locationLoop: for (Iterator<Location> iter = cfg.locationIterator(); iter.hasNext();) {
            Location location = iter.next();
            InstructionHandle handle = location.getHandle();
            Instruction ins = handle.getInstruction();

            // Only consider invoke instructions
            if (!(ins instanceof InvokeInstruction)) {
                continue;
View Full Code Here

        if (DEBUG) {
            System.out.println("**** Analyzing method " + SignatureConverter.convertMethodSignature(methodGen));
        }

        for (Iterator<Location> i = cfg.locationIterator(); i.hasNext();) {
            Location location = i.next();
            try {
                Instruction ins = location.getHandle().getInstruction();
                XField xfield = null;
                boolean isWrite = false;
                boolean isLocal = false;
                boolean isNullCheck = false;

                if (ins instanceof FieldInstruction) {
                    InstructionHandle n = location.getHandle().getNext();
                    isNullCheck = n.getInstruction() instanceof IFNONNULL || n.getInstruction() instanceof IFNULL;
                    if (DEBUG && isNullCheck) {
                        System.out.println("is null check");
                    }
                    FieldInstruction fins = (FieldInstruction) ins;
                    xfield = Hierarchy.findXField(fins, cpg);
                    if (xfield == null) {
                        continue;
                    }
                    isWrite = ins.getOpcode() == Constants.PUTFIELD;
                    isLocal = fins.getClassName(cpg).equals(classContext.getJavaClass().getClassName());
                    if (DEBUG) {
                        System.out.println("Handling field access: " + location.getHandle() + " (frame="
                                + vnaDataflow.getFactAtLocation(location) + ") :" + n);
                    }
                } else if (ins instanceof INVOKESTATIC) {
                    INVOKESTATIC inv = (INVOKESTATIC) ins;
                    InnerClassAccess access = icam.getInnerClassAccess(inv, cpg);
                    if (access != null && access.getMethodSignature().equals(inv.getSignature(cpg))) {
                        xfield = access.getField();
                        isWrite = !access.isLoad();
                        isLocal = false;
                        if (DEBUG) {
                            System.out.println("Handling inner class access: " + location.getHandle() + " (frame="
                                    + vnaDataflow.getFactAtLocation(location) + ")");
                        }
                    }
                }

                if (xfield == null) {
                    continue;
                }

                // We only care about mutable nonvolatile nonpublic instance
                // fields.
                if (xfield.isStatic() || xfield.isPublic() || xfield.isVolatile() || xfield.isFinal()) {
                    continue;
                }

                // The value number frame could be invalid if the basic
                // block became unreachable due to edge pruning (dead code).
                ValueNumberFrame frame = vnaDataflow.getFactAtLocation(location);
                if (!frame.isValid()) {
                    continue;
                }

                // Get lock set and instance value
                ValueNumber thisValue = !method.isStatic() ? vnaDataflow.getAnalysis().getThisValue() : null;
                LockSet lockSet = lockChecker.getFactAtLocation(location);
                InstructionHandle handle = location.getHandle();
                ValueNumber instance = frame.getInstance(handle.getInstruction(), cpg);
                if (DEBUG) {
                    System.out.println("Lock set: " + lockSet);
                    System.out.println("value number: " + instance.getNumber());
                    System.out.println("Lock count: " + lockSet.getLockCount(instance.getNumber()));
View Full Code Here

        // Find all obviously locked call sites
        Set<CallSite> obviouslyLockedSites = new HashSet<CallSite>();
        for (Iterator<CallSite> i = selfCalls.callSiteIterator(); i.hasNext();) {
            CallSite callSite = i.next();
            Method method = callSite.getMethod();
            Location location = callSite.getLocation();
            InstructionHandle handle = location.getHandle();

            // Only instance method calls qualify as candidates for
            // "obviously locked"
            Instruction ins = handle.getInstruction();
            if (ins.getOpcode() == Constants.INVOKESTATIC) {
View Full Code Here

TOP

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

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.