Description
The immutable data structures are strictly immutable by design.
However currently, they allow indirect modification after initialisation.
Reproducible
always
Steps to reproduce
Add the following test cases to class ImmutableListArrayTest
@Test
void immutability1() {
Integer[] array = { 0, 1, 4};
ImmutableListArray<Integer> list = new ImmutableListArray<>(array);
array[2] = 2;
assertThat(list.get(2)).isEqualTo(4);
}
@Test
void immutability2() {
Integer[] array = { 0, 1, 4};
ImmutableList<Integer> list = ImmutableList.fromArray(array);
array[2] = 2;
assertThat(list.get(2)).isEqualTo(4);
}
They fail. In both cases the value list.get(2) is 2.
Additional information
Description
The immutable data structures are strictly immutable by design.
However currently, they allow indirect modification after initialisation.
Reproducible
always
Steps to reproduce
Add the following test cases to class
ImmutableListArrayTestThey fail. In both cases the value
list.get(2)is 2.Additional information