Back to Intellij Community

SuspiciousSystemArraycopy

java/java-impl/resources/inspectionDescriptions/SuspiciousSystemArraycopy.html

2025.3-rc-2584 B
Original Source

Reports suspicious calls to System.arraycopy().

Such calls are suspicious when:

  • the source or destination is not of an array type
  • the source and destination are of different types
  • the copied chunk length is greater than src.length - srcPos
  • the copied chunk length is greater than dest.length - destPos
  • the ranges always intersect when the source and destination are the same array

Example:

void foo() {
    int[] src = new int[] { 1, 2, 3, 4 };
    System.arraycopy(src, 0, src, 1, 2); // warning: Copying to the same array with intersecting ranges
  }