An array is copied element by element in a loop
What it finds
for (int i = 0; i < n; i++) target[i] = source[i]; copies one element per pass, where System.arraycopy or Arrays.copyOf copy the block at once and say what happens.
Reported is a counting for loop whose only statement assigns a[i] = b[i], with the same counter on both sides.
From the rule's source, manual_array_copy.rs.
class Copy { void copy(int[] source, int[] target, int n) { for (int i = 0; i < n; i++) { target[i] = source[i];tx0 reports: System.arraycopy does it at once } for (int i = 0; i < n; i++) { target[i] = source[i] * 2; } }} Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/java:manual-array-copy" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/java:manual-array-copy] reason="..."tx0 explain tx0/java:manual-array-copy shows the same in the terminal. Found a false positive? Report it.