-
Enhancement
-
Resolution: Unresolved
-
P4
-
None
-
None
-
None
Add an Arrays.asUnmodifiableList() API. This is similar to Arrays.asList(), which returns a List that wraps an array. The difference is that, unlike Arrays.asList, the new API will return an unmodifiable List.
It should probably be a varargs method, like Arrays.asList. However the retrofit of varargs onto Arrays.asList was something of a problem (it seems to cause some ambiguities -- need to check this) so we might reconsider this.
The implementation will probably need to be a new class that overrides all the mutator methods so as to provide strict UnsupportedOperationException throwing. It should avoid the problems with things like `Collections.singleton("abc").remove(123)` which is a no-op instead of throwing UOE. Care should be taken to ensure the views (sublist, reversed) are also strictly unmodifiable.
It should probably be a varargs method, like Arrays.asList. However the retrofit of varargs onto Arrays.asList was something of a problem (it seems to cause some ambiguities -- need to check this) so we might reconsider this.
The implementation will probably need to be a new class that overrides all the mutator methods so as to provide strict UnsupportedOperationException throwing. It should avoid the problems with things like `Collections.singleton("abc").remove(123)` which is a no-op instead of throwing UOE. Care should be taken to ensure the views (sublist, reversed) are also strictly unmodifiable.