Files
openide/java/java-tests/testData/inspection/dataFlow/fixture/ArrayInitializersWithMethodCall.java
Tagir Valeev a26d25a99f [java-dfa] Do not report array as immutable if it's passed to pure methods that return unmodifiable object
The object may be only shallowly unmodifiable

GitOrigin-RevId: 41c0a0b46fc80169ff334d6337d9f8708e689448
2024-06-10 18:10:55 +00:00

20 lines
465 B
Java

import java.util.Arrays;
class Test {
void test(int[] dest) {
int[] array = {1, 2, 3, 4, 5};
System.out.println(Arrays.toString(array));
System.arraycopy(array, 0, dest, 0, 5);
// Analysis cannot see this, unfortunately
if (array[3] == 4) {
}
}
void test2(int[] dest) {
int[] array = {1, 2, 3, 4, 5};
System.out.println(Arrays.toString(array));
System.arraycopy(dest, 0, array, 0, 5);
if (array[3] == 4) {
}
}
}