Inspectopedia Help

Suspicious 'System.arraycopy()' call

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 }

Inspection Details

By default bundled with:

IntelliJ IDEA 2024.1, Qodana for JVM 2024.1,

Can be installed with plugin:

Java, 241.16690

Last modified: 29 April 2024