Examples of XField


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

                        if (e.getSignature().indexOf("Logger") >= 0 || e.getSignature().indexOf("Exception") >= 0) {
                            debuggingContext = true;
                        }

                        XField f = e.getXField();
                        if (f != null && (SYSTEM_ERR.equals(f.getFieldDescriptor()) || SYSTEM_OUT.equals(f.getFieldDescriptor()))) {
                            debuggingContext = true;
                        }
                    }
                }
                //                String name = null;
                int reg = item.getRegisterNumber();
                Collection<BugAnnotation> as = new ArrayList<BugAnnotation>();
                XField field = item.getXField();
                FieldAnnotation fieldAnnotation = null;
                if (field != null) {
                    fieldAnnotation = FieldAnnotation.fromXField(field);
                    fieldAnnotation.setDescription(FieldAnnotation.LOADED_FROM_ROLE);
                }
View Full Code Here

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

        case GETSTATIC:
        case PUTSTATIC:
        case GETFIELD:
        case PUTFIELD: {
            XField f = getXFieldOperand();
            if (f != null) {
                Collection<TypeQualifierAnnotation> annotations = TypeQualifierApplications.getApplicableApplications(f);
                Analysis.addKnownTypeQualifiers(applicableApplications, annotations);
            }
View Full Code Here

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

        }

        @Override
        public void visitGETSTATIC(GETSTATIC obj) {
            Type type = obj.getType(getCPG());
            XField xf = XFactory.createXField(obj, cpg);
            if (xf.isFinal()) {
                FieldSummary fieldSummary = AnalysisContext.currentAnalysisContext().getFieldSummary();
                Item summary = fieldSummary.getSummary(xf);
                if (summary.isNull()) {
                    pushValue(TypeFrame.getNullType());
                    return;
View Full Code Here

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

        public void visitGETFIELD(GETFIELD obj) {
            Type type = obj.getType(getCPG());
            if (type.getSignature().equals(STRING_SIGNATURE)) {
                handleLoad(obj);
            } else {
                XField xf = XFactory.createXField(obj, cpg);
                if (xf.isFinal()) {
                    FieldSummary fieldSummary = AnalysisContext.currentAnalysisContext().getFieldSummary();
                    Item summary = fieldSummary.getSummary(xf);
                    if (summary.isNull()) {
                        consumeStack(obj);
                        pushValue(TypeFrame.getNullType());
View Full Code Here

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

        }

        else if (seen == PUTFIELD && stack.getStackDepth() >= 2) {
            OpcodeStack.Item obj = stack.getStackItem(1);
            if (obj.getRegisterNumber() == 0) {
                XField f = getXFieldOperand();
                if (potentiallyDeadFields.contains(f) && potentiallyDeadFieldsFromBeforeFallthrough.contains(f)) {
                    // killed store
                    priority = HIGH_PRIORITY;
                    bugAccumulator.accumulateBug(new BugInstance(this, "SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH", priority)
                    .addClassAndMethod(this).addField(f), this);
View Full Code Here

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

            if (!(fieldType instanceof ReferenceType)) {
                continue;
            }

            // Find the exact field being stored into
            XField xfield = Hierarchy.findXField(fins, cpg);
            if (xfield == null) {
                continue;
            }

            // Skip public and protected fields, since it is reasonable to
            // assume
            // we won't see every store to those fields
            if (xfield.isPublic() || xfield.isProtected()) {
                continue;
            }

            // The top value on the stack is the one which will be stored
            // into the field
            TypeFrame frame = typeDataflow.getFactAtLocation(location);
            if (!frame.isValid()) {
                continue;
            }
            Type storeType = frame.getTopValue();
            if (!(storeType instanceof ReferenceType)) {
                continue;
            }

            // Get or create the field store type set
            FieldStoreType property = database.getProperty(xfield.getFieldDescriptor());
            if (property == null) {
                property = new FieldStoreType();
                database.setProperty(xfield.getFieldDescriptor(), property);
            }

            // Add the store type to the set
            property.addTypeSignature(storeType.getSignature());
        }
View Full Code Here

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

        Binding binding = bindingSet.lookup("f");

        // Look up the field as an XField.
        // If it is volatile, then the instance is not a bug.
        FieldVariable field = (FieldVariable) binding.getVariable();
        XField xfield = Hierarchy.findXField(field.getClassName(), field.getFieldName(), field.getFieldSig(),
                field.isStatic());
        if (!xfield.isResolved()) {
            return;
        }

        // XXX: for now, ignore lazy initialization of instance fields
        if (!xfield.isStatic()) {
            return;
        }

        // Definitely ignore synthetic class$ fields
        if (xfield.getName().startsWith("class$") || xfield.getName().startsWith("array$")) {
            if (DEBUG) {
                System.out.println("Ignoring field " + xfield.getName());
            }
            return;
        }

        // Ignore non-reference fields
        String signature = xfield.getSignature();
        if (!signature.startsWith("[") && !signature.startsWith("L")) {
            if (DEBUG) {
                System.out.println("Ignoring non-reference field " + xfield.getName());
            }
            return;
        }

        // Strings are (mostly) safe to pass by data race in 1.5
        if (signature.equals("Ljava/lang/String;")) {
            return;
        }

        // GUI types should not be accessed from multiple threads

        if (signature.charAt(0) == 'L') {
            ClassDescriptor fieldType = DescriptorFactory.createClassDescriptorFromFieldSignature(signature);

            while (fieldType != null) {
                XClass fieldClass;
                try {
                    fieldClass = Global.getAnalysisCache().getClassAnalysis(XClass.class, fieldType);
                } catch (CheckedAnalysisException e) {
                    break;
                }

                String name = fieldClass.getClassDescriptor().getClassName();
                if (name.startsWith("java/awt") || name.startsWith("javax/swing")) {
                    return;
                }
                if (name.equals("java/lang/Object")) {
                    break;
                }
                fieldType = fieldClass.getSuperclassDescriptor();
            }
        }

        // Get locations matching the beginning of the object creation,
        // and the final field store.
        PatternElementMatch createBegin = match.getFirstLabeledMatch("createObject");
        PatternElementMatch store = match.getFirstLabeledMatch("end");
        PatternElementMatch test = match.getFirstLabeledMatch("test");
        InstructionHandle testInstructionHandle = test.getMatchedInstructionInstructionHandle();
        if (reported.get(testInstructionHandle.getPosition())) {
            return;
        }

        // Get all blocks
        //
        // (1) dominated by the wildcard instruction matching
        // the beginning of the instructions creating the object, and
        // (2) postdominated by the field store
        //
        // Exception edges are not considered in computing
        // dominators/postdominators.
        // We will consider this to be all of the code that creates
        // the object.
        DominatorsAnalysis domAnalysis = classContext.getNonExceptionDominatorsAnalysis(method);
        PostDominatorsAnalysis postDomAnalysis = classContext.getNonExceptionPostDominatorsAnalysis(method);
        BitSet extent = domAnalysis.getAllDominatedBy(createBegin.getBasicBlock());
        BitSet postDom = postDomAnalysis.getAllDominatedBy(store.getBasicBlock());
        // System.out.println("Extent: " + extent);
        if (DEBUG) {
            System.out.println("test  dominates: " + extent);
            System.out.println("Field store postdominates " + postDom);
        }
        extent.and(postDom);
        if (DEBUG) {
            System.out.println("extent: " + extent);
        }
        // Check all instructions in the object creation extent
        //
        // (1) to determine the common lock set, and
        // (2) to check for NEW and Invoke instructions that might create an
        // object
        //
        // We ignore matches where a lock is held consistently,
        // or if the extent does not appear to create a new object.
        LockDataflow lockDataflow = classContext.getLockDataflow(method);
        LockSet lockSet = null;
        boolean sawNEW = false, sawINVOKE = false;
        for (BasicBlock block : cfg.getBlocks(extent)) {
            for (Iterator<InstructionHandle> j = block.instructionIterator(); j.hasNext();) {
                InstructionHandle handle = j.next();
                if (handle.equals(store.getMatchedInstructionInstructionHandle())) {
                    break;
                }
                Location location = new Location(handle, block);

                // Keep track of whether we saw any instructions
                // that might actually have created a new object.
                Instruction ins = handle.getInstruction();
                if (DEBUG) {
                    System.out.println(location);
                }
                if (ins instanceof AllocationInstruction) {
                    sawNEW = true;
                } else if (ins instanceof InvokeInstruction) {
                    if (ins instanceof INVOKESTATIC
                            && ((INVOKESTATIC) ins).getMethodName(classContext.getConstantPoolGen()).startsWith("new")) {
                        sawNEW = true;
                    }
                    sawINVOKE = true;
                }

                // Compute lock set intersection for all matched
                // instructions.
                LockSet insLockSet = lockDataflow.getFactAtLocation(location);
                if (lockSet == null) {
                    lockSet = new LockSet();
                    lockSet.copyFrom(insLockSet);
                } else {
                    lockSet.intersectWith(insLockSet);
                }
            }
        }

        if (!(sawNEW || sawINVOKE)) {
            return;
        }
        if (lockSet == null) {
            throw new IllegalStateException("lock set is null");
        }
        if (!lockSet.isEmpty()) {
            return;
        }

        boolean sawGetStaticAfterPutStatic = false;
        check: if (signature.startsWith("[") || signature.startsWith("L")) {

            BitSet postStore = domAnalysis.getAllDominatedBy(store.getBasicBlock());
            for (BasicBlock block : cfg.getBlocks(postStore)) {
                for (Iterator<InstructionHandle> j = block.instructionIterator(); j.hasNext();) {
                    InstructionHandle handle = j.next();

                    InstructionHandle nextHandle = handle.getNext();
                    Instruction ins = handle.getInstruction();

                    if (ins instanceof GETSTATIC && potentialInitialization(nextHandle)) {
                        XField field2 = XFactory.createXField((FieldInstruction) ins, methodGen.getConstantPool());
                        if (xfield.equals(field2)) {
                            sawGetStaticAfterPutStatic = true;
                            break check;
                        }
                    }
View Full Code Here

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

            }

        }
        if (seen == PUTSTATIC && getClassConstantOperand().equals(getClassName())) {
            XField f = getXFieldOperand();
            if (prev != null) {
                prev.field = f;
            }
            if (staticFieldsReadInAnyConstructor.contains(f) && !warningGiven.contains(f)) {
                for(InvocationInfo i : invocationInfo) {
View Full Code Here

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

    public static @CheckForNull
    BugAnnotation getFieldOrMethodValueSource(@CheckForNull OpcodeStack.Item item) {
        if (item == null) {
            return null;
        }
        XField xField = item.getXField();
        if (xField != null) {
            FieldAnnotation a = FieldAnnotation.fromXField(xField);
            a.setDescription(FieldAnnotation.LOADED_FROM_ROLE);
            return a;
        }
View Full Code Here

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

        try {
            if (getSuperclassDescriptor() == null) {
                return null;
            }
            XClass superClass = Global.getAnalysisCache().getClassAnalysis(XClass.class, getSuperclassDescriptor());
            XField result = superClass.findField(name, signature, isStatic);
            if (result != null) {
                return result;
            }
            if (!isStatic) {
                return null;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.