Class StringConcatenation

  • All Implemented Interfaces:
    Detector, Priorities, StatelessDetector, java.lang.Cloneable, org.apache.bcel.classfile.Visitor

    public class StringConcatenation
    extends OpcodeStackDetector
    implements StatelessDetector
    Find occurrences of using the String "+" or "+=" operators within a loop. This is much less efficient than creating a dedicated StringBuffer object outside the loop, and then appending to it.
    • Field Detail

      • DEBUG

        private static final boolean DEBUG
      • CONSTRUCTED_STRING_ON_STACK

        static final int CONSTRUCTED_STRING_ON_STACK
        See Also:
        Constant Field Values
      • reportedThisMethod

        private boolean reportedThisMethod
      • stringSource

        private int stringSource
      • createPC

        private int createPC
      • state

        private int state
      • clobberedRegisters

        private java.util.Map<java.lang.Integer,​java.lang.Integer> clobberedRegisters
    • Constructor Detail

      • StringConcatenation

        public StringConcatenation​(BugReporter bugReporter)
    • Method Detail

      • visit

        public void visit​(org.apache.bcel.classfile.Method obj)
        Overrides:
        visit in class BetterVisitor
      • reset

        private void reset()
      • storeIntoRegister

        private boolean storeIntoRegister​(int seen,
                                          int reg)
      • getRegisterOnStack

        private int getRegisterOnStack()
      • getRegisterOnStack

        private int getRegisterOnStack​(int idx)