Class InefficientInitializationInsideLoop

All Implemented Interfaces:
Detector, Priorities, org.apache.bcel.classfile.Visitor

public class InefficientInitializationInsideLoop extends OpcodeStackDetector
  • Field Details

  • Constructor Details

    • InefficientInitializationInsideLoop

      public InefficientInitializationInsideLoop(BugReporter bugReporter)
  • Method Details

    • 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
      Overrides:
      visitClassContext in class BytecodeScanningDetector
      Parameters:
      classContext - the ClassContext
    • visitMethod

      public void visitMethod(org.apache.bcel.classfile.Method obj)
      Specified by:
      visitMethod in interface org.apache.bcel.classfile.Visitor
      Overrides:
      visitMethod in class BetterVisitor
    • isFastPath

      private boolean isFastPath(String regex)
      Since JDK 1.7 there's a special branch in String.split which works very fast for one-character pattern We do not report a bug if this case takes place (in fact precompilation will make split much slower since this fast path doesn't use regexp engine at all)
      Parameters:
      regex - regex to test whether it's suitable for the fast path
      Returns:
      true if fast path is possible
    • sawOpcode

      public void sawOpcode(int seen)
      Description copied from class: OpcodeStackDetector

      By default, this method will not be called when stack is TOP. To change this behavior, override #beforeOpcode(int) and change to return true even if stack is TOP.

      see Using FindBugs for Research to learn lattice and what TOP means.

      Specified by:
      sawOpcode in class OpcodeStackDetector
      See Also:
    • getFirstArgument

      private String getFirstArgument()
      Returns:
      first argument of the called method if it's a constant
    • hasConstantArguments

      private boolean hasConstantArguments()
      Returns:
      true if only constants are passed to the called method