Add Arrays.asUnmodifiableList

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Unresolved
    • Priority: P4
    • None
    • Affects Version/s: None
    • Component/s: core-libs
    • 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.

            Assignee:
            kevin bourrillion
            Reporter:
            Stuart Marks
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: