Class InefficientToArray

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

public class InefficientToArray extends BytecodeScanningDetector implements StatelessDetector
Find occurrences of collection.toArray( new Foo[0] ); This causes another memory allocation through reflection Much better to do collection.toArray( new Foo[collection.size()] );
  • Field Details

    • DEBUG

      private static final boolean DEBUG
    • methods

      private static final List<MethodDescriptor> methods
    • SEEN_NOTHING

      static final int SEEN_NOTHING
      See Also:
    • SEEN_ICONST_0

      static final int SEEN_ICONST_0
      See Also:
    • SEEN_ANEWARRAY

      static final int SEEN_ANEWARRAY
      See Also:
    • collectionClass

      private static final org.apache.bcel.classfile.JavaClass collectionClass
    • bugReporter

      private final BugReporter bugReporter
    • bugAccumulator

      private final BugAccumulator bugAccumulator
    • state

      private int state
  • Constructor Details

    • InefficientToArray

      public InefficientToArray(BugReporter bugReporter)
  • Method Details