Class FindDeadLocalStores

  • All Implemented Interfaces:
    Detector, Priorities

    public class FindDeadLocalStores
    extends java.lang.Object
    implements Detector
    Find dead stores to local variables.
    • Field Detail

      • DEBUG

        private static final boolean DEBUG
      • FINDBUGS_EXCLUDED_LOCALS_PROP_NAME

        private static final java.lang.String FINDBUGS_EXCLUDED_LOCALS_PROP_NAME
        See Also:
        Constant Field Values
      • EXCLUDED_LOCALS

        @StaticConstant
        private static final java.util.Set<java.lang.String> EXCLUDED_LOCALS
      • SUPPRESS_IF_AT_LEAST_ONE_LIVE_STORE_ON_LINE

        private static final boolean SUPPRESS_IF_AT_LEAST_ONE_LIVE_STORE_ON_LINE
        System property to enable a feature that suppresses warnings if there is at least one live store on the line where the warning would be reported. Eliminates some FPs due to inlining/duplication of finally blocks. But, kills some legitimate warnings where there are truly multiple stores on the same line.
      • defensiveConstantValueOpcodes

        private static final java.util.BitSet defensiveConstantValueOpcodes
        Opcodes of instructions that load constant values that often indicate defensive programming.
    • Constructor Detail

      • FindDeadLocalStores

        public FindDeadLocalStores​(BugReporter bugReporter)
    • Method Detail

      • prescreen

        private boolean prescreen​(ClassContext classContext,
                                  org.apache.bcel.classfile.Method method)
      • visitClassContext

        public void visitClassContext​(ClassContext classContext)
        Description copied from interface: Detector
        Visit the ClassContext for a class which should be analyzed for instances of bug patterns.
        Specified by:
        visitClassContext in interface Detector
        Parameters:
        classContext - the ClassContext
      • suppressWarningsIfOneLiveStoreOnLine

        private void suppressWarningsIfOneLiveStoreOnLine​(BugAccumulator accumulator,
                                                          java.util.BitSet liveStoreSourceLineSet)
        If feature is enabled, suppress warnings where there is at least one live store on the line where the warning would be reported.
        Parameters:
        accumulator - BugAccumulator containing warnings for method
        liveStoreSourceLineSet - bitset of lines where at least one live store was seen
      • countLocalStoresLoadsAndIncrements

        private void countLocalStoresLoadsAndIncrements​(int[] localStoreCount,
                                                        int[] localLoadCount,
                                                        int[] localIncrementCount,
                                                        CFG cfg)
        Count stores, loads, and increments of local variables in method whose CFG is given.
        Parameters:
        localStoreCount - counts of local stores (indexed by local)
        localLoadCount - counts of local loads (indexed by local)
        localIncrementCount - counts of local increments (indexed by local)
        cfg - control flow graph (CFG) of method
      • isStore

        private boolean isStore​(Location location)
        Is instruction at given location a store?
        Parameters:
        location - the location
        Returns:
        true if instruction at given location is a store, false if not
      • isLoad

        private boolean isLoad​(Location location)
        Is instruction at given location a load?
        Parameters:
        location - the location
        Returns:
        true if instruction at given location is a load, false if not
      • report

        public void report()
        Description copied from interface: Detector
        This method is called after all classes to be visited. It should be used by any detectors which accumulate information over all visited classes to generate results.
        Specified by:
        report in interface Detector