[10?] RFR: 8193128: Reduce number of implementation classes returned by List/Set/Map.of()
claes.redestad at oracle.com
Thu Dec 7 23:41:55 UTC 2017
On 2017-12-07 01:12, Claes Redestad wrote:
> SubList is now final, inherits from AbstractImmutableList instead of
> AbstractList and reuses more of the shared code.
> I also moved 'implements Serializable' from AbstractImmutableList to
> List12 and ListN respectively to not
> change the behavior that List.of(0,1) is serializable while
> List.of(0,1).subList(0,1) isn't.
While doing this, I realized a few issues with my patch around the
- I had "optimized" AbstractImmutable::subList to return self or
emptyList if appropriate, which sounded nice, but is in fact an
incompatible change (some subLists become Serializable).
- the ListFactories test didn't explicitly verify that sublists
retrieved from various List.of() impls aren't Serializable. Added tests
to check no sub-list is Serializable,
and as a bonus this test now verifies that List.of(...).subList(...)
behave like their List.of(..) counterparts in most other ways.
- fixed range check in AbstractImmutableList.listIterator(0) to not
throw IOOBE if the list is empty
More information about the core-libs-dev