All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.umd.cs.findbugs.detect.UnreadFieldsData Maven / Gradle / Ivy

The newest version!
/*
 * FindBugs - Find Bugs in Java programs
 * Copyright (C) 2003-2008 University of Maryland
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package edu.umd.cs.findbugs.detect;

import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;

import edu.umd.cs.findbugs.ProgramPoint;
import edu.umd.cs.findbugs.SourceLineAnnotation;
import edu.umd.cs.findbugs.ba.XField;
import edu.umd.cs.findbugs.classfile.ClassDescriptor;
import edu.umd.cs.findbugs.util.MultiMap;

/**
 * @author  pugh
 */
public class UnreadFieldsData {
    final Map> assumedNonNull = new HashMap<>();

    final Map threadLocalAssignedInConstructor = new HashMap<>();

    final Set nullTested = new HashSet<>();

    final Set containerFields = new TreeSet<>();

    final MultiMap unknownAnnotation = new MultiMap<>(LinkedList.class);

    final Set abstractClasses = new HashSet<>();

    final Set hasNonAbstractSubClass = new HashSet<>();

    final Set classesScanned = new HashSet<>();

    final Set fieldsOfNativeClasses = new HashSet<>();

    final Set reflectiveFields = new HashSet<>();

    final Set fieldsOfSerializableOrNativeClassed = new HashSet<>();

    final Set staticFieldsReadInThisMethod = new HashSet<>();

    final Set allMyFields = new TreeSet<>();

    final Set myFields = new TreeSet<>();

    final Set writtenFields = new HashSet<>();


    final Map fieldAccess = new HashMap<>();

    final Set writtenNonNullFields = new HashSet<>();

    final Set calledFromConstructors = new HashSet<>();

    final Set writtenInConstructorFields = new HashSet<>();

    final Set writtenInInitializationFields = new HashSet<>();

    final Set writtenOutsideOfInitializationFields = new HashSet<>();

    final Set readFields = new HashSet<>();

    final Set constantFields = new HashSet<>();

    final Set needsOuterObjectInConstructor = new HashSet<>();

    final Set innerClassCannotBeStatic = new HashSet<>();

    final HashSet toldStrongEvidenceForIntendedSerialization = new HashSet<>();

    public boolean isContainerField(XField f) {
        return containerFields.contains(f);
    }

    public void strongEvidenceForIntendedSerialization(ClassDescriptor c) {
        toldStrongEvidenceForIntendedSerialization.add(c);
    }

    public boolean existsStrongEvidenceForIntendedSerialization(ClassDescriptor c) {
        return toldStrongEvidenceForIntendedSerialization.contains(c);
    }

    public boolean isWrittenOutsideOfInitialization(XField f) {
        return writtenOutsideOfInitializationFields.contains(f);
    }

    public boolean isReflexive(XField f) {
        return reflectiveFields.contains(f);
    }

    public Set getReadFields() {
        return readFields;
    }

    public Set getWrittenFields() {
        return writtenFields;
    }

    public boolean isWrittenInConstructor(XField f) {
        return writtenInConstructorFields.contains(f);
    }

    public boolean isWrittenDuringInitialization(XField f) {
        return writtenInInitializationFields.contains(f);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy