Package edu.umd.cs.findbugs.ba

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


                } catch (DataflowAnalysisException e) {
                    throw new InvalidBytecodeException("stack underflow", methodGen, handle, e);
                }
            } else if (Hierarchy.isInnerClassAccess(obj, cpg)) {
                // Possible access of field via an inner-class access method
                XField xfield = loadedFieldSet.getField(handle);
                if (xfield != null) {
                    if (loadedFieldSet.instructionIsLoad(handle)) {
                        // Load via inner-class accessor
                        if (doRedundantLoadElimination()) {
                            if (xfield.isStatic()) {
                                loadStaticField(xfield, obj);
                            } else {
                                loadInstanceField(xfield, obj);
                            }
                            return;
                        }
                    } else {
                        // Store via inner-class accessor
                        if (doForwardSubstitution()) {
                            // Some inner class access store methods
                            // return the value stored.
                            boolean pushValue = !methodSig.endsWith(")V");

                            if (xfield.isStatic()) {
                                storeStaticField(xfield, obj, pushValue);
                            } else {
                                storeInstanceField(xfield, obj, pushValue);
                            }
View Full Code Here


        return null;
    }

    public static FieldAnnotation findFieldAnnotationFromValueNumber(Method method, Location location, ValueNumber valueNumber,
            ValueNumberFrame vnaFrame) {
        XField field = ValueNumberSourceInfo.findXFieldFromValueNumber(method, location, valueNumber, vnaFrame);
        if (field == null) {
            return null;
        }
        return FieldAnnotation.fromXField(field);
    }
View Full Code Here

        for (Map.Entry<String, SortedSet<String>> e : map.entrySet()) {
            Set<String> occursIn = e.getValue();
            if (occursIn.size() == 1) {
                continue;
            }
            XField field = definition.get(e.getKey());
            if (field == null) {
                continue;
            }
            Integer length = stringSize.get(e.getKey());
            int overhead = length * (occursIn.size() - 1);
            if (overhead < 3 * SIZE_OF_HUGE_CONSTANT) {
                continue;
            }
            String className = field.getClassName();

            BugInstance bug = new BugInstance(this, "HSC_HUGE_SHARED_STRING_CONSTANT",
                    overhead > 20 * SIZE_OF_HUGE_CONSTANT ? HIGH_PRIORITY
                            : (overhead > 8 * SIZE_OF_HUGE_CONSTANT ? NORMAL_PRIORITY : LOW_PRIORITY)).addClass(className)
                            .addField(field).addInt(length).addInt(occursIn.size()).describe(IntAnnotation.INT_OCCURRENCES);
View Full Code Here

            System.out.println("  isJSPClass: " + isJSPClass);
        }
        if (isSerializable && !sawReadObject && !sawReadResolve && seenTransientField && !superClassHasReadObject) {
            for (Map.Entry<XField, Integer> e : transientFieldsUpdates.entrySet()) {

                XField fieldX = e.getKey();
                int priority = NORMAL_PRIORITY;
                if (transientFieldsSetInConstructor.contains(e.getKey())) {
                    priority--;
                }

                if (isGUIClass) {
                    priority++;
                }
                if (isEjbImplClass) {
                    priority++;
                }
                if (isJSPClass) {
                    priority++;
                }
                if (e.getValue() < 3) {
                    priority++;
                }
                if (transientFieldsSetToDefaultValueInConstructor.contains(e.getKey())) {
                    priority++;
                }
                if (obj.isAbstract()) {
                    priority++;
                    if (priority < Priorities.LOW_PRIORITY) {
                        priority = Priorities.LOW_PRIORITY;
                    }
                }

                try {
                    double isSerializable = DeepSubtypeAnalysis.isDeepSerializable(fieldX.getSignature());
                    if (isSerializable < 0.6) {
                        priority++;
                    }
                } catch (ClassNotFoundException e1) {
                    // ignore it
View Full Code Here

    }

    @Override
    public void sawOpcode(int seen) {
        if (seen == PUTFIELD) {
            XField xField = getXFieldOperand();
            if (xField != null && xField.getClassDescriptor().equals(getClassDescriptor())) {
                Item first = stack.getStackItem(0);

                boolean isPutOfDefaultValue = first.isNull(); // huh?? ||
                // first.isInitialParameter();
                if (!isPutOfDefaultValue && first.getConstant() != null) {
                    Object constant = first.getConstant();
                    if (constant instanceof Number && ((Number) constant).intValue() == 0 || constant.equals(Boolean.FALSE)) {
                        isPutOfDefaultValue = true;
                    }
                }

                if (isPutOfDefaultValue) {
                    if (getMethodName().equals("<init>")) {
                        transientFieldsSetToDefaultValueInConstructor.add(xField);
                    }
                } else {
                    String nameOfField = getNameConstantOperand();

                    if (transientFieldsUpdates.containsKey(xField)) {
                        if (getMethodName().equals("<init>")) {
                            transientFieldsSetInConstructor.add(xField);
                        } else {
                            transientFieldsUpdates.put(xField, transientFieldsUpdates.get(xField) + 1);
                        }
                    } else if (fieldsThatMightBeAProblem.containsKey(nameOfField)) {
                        try {

                            JavaClass classStored = first.getJavaClass();
                            if (classStored == null) {
                                return;
                            }
                            double isSerializable = DeepSubtypeAnalysis.isDeepSerializable(classStored);
                            if (isSerializable <= 0.2) {
                                XField f = fieldsThatMightBeAProblem.get(nameOfField);

                                String sig = f.getSignature();
                                // System.out.println("Field signature: " +
                                // sig);
                                // System.out.println("Class stored: " +
                                // classStored.getClassName());
                                String genSig = "L" + classStored.getClassName().replace('.', '/') + ";";
View Full Code Here

        } else if (getClassName().indexOf("ObjectStreamClass") == -1 && isSerializable && !isExternalizable
                && fieldSig.indexOf('L') >= 0 && !obj.isTransient() && !obj.isStatic()) {
            if (DEBUG) {
                System.out.println("Examining non-transient field with name: " + getFieldName() + ", sig: " + fieldSig);
            }
            XField xfield = getXField();
            Type type = TypeFrameModelingVisitor.getType(xfield);
            if (type instanceof ReferenceType) {
                try {
                    ReferenceType rtype = (ReferenceType) type;
View Full Code Here

            if (iins.getMethodName(cpg).equals("close") && iins.getSignature(cpg).equals("()V")) {
                propertySet.addProperty(NullDerefProperty.CLOSING_NULL);
            }
        } else if (ins instanceof FieldInstruction) {
            FieldInstruction fins = (FieldInstruction) ins;
            XField referencedField = XFactory.createXField(fins, cpg);
            cause = FieldAnnotation.fromXField(referencedField);

        } else {
            cause = new StringAnnotation(ins.getName());
        }
View Full Code Here

                    pendingBug.addString(value).describe(StringAnnotation.STRING_CONSTANT_ROLE);
                }

            } else if (badSignatures.contains(syncSignature)) {
                isSyncOnBoolean = syncSignature.equals("Ljava/lang/Boolean;");
                XField field = top.getXField();
                FieldSummary fieldSummary = AnalysisContext.currentAnalysisContext().getFieldSummary();
                OpcodeStack.Item summary = fieldSummary.getSummary(field);
                int priority = NORMAL_PRIORITY;
                if (isSyncOnBoolean) {
                    priority--;
View Full Code Here

            }

        }

        if (seen == PUTFIELD || seen == PUTSTATIC) {
            XField fieldOperand = getXFieldOperand();
            if (fieldOperand == null) {
                return;
            }
            touched.add(fieldOperand);
            if (!fieldOperand.getClassDescriptor().getClassName().equals(getClassName())) {
                fieldSummary.addWrittenOutsideOfConstructor(fieldOperand);
            } else if (seen == PUTFIELD) {
                OpcodeStack.Item addr = stack.getStackItem(1);
                {
                    if (addr.getRegisterNumber() != 0 || !getMethodName().equals("<init>")) {
View Full Code Here

                bugReporter.logError("Error analyzing method", e);
            }
        }
        for (Field f : javaClass.getFields()) {
            if (f.isPrivate()) {
                XField xf = XFactory.getExactXField(classContext.getClassDescriptor().getClassName(), f);
                FieldStats stats = statMap.get(xf);
                if (stats == null) {
                    continue;
                }
                if (!stats.isServletField() && !stats.hasAnySynchronizedAccesses()) {
View Full Code Here

TOP

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

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.