Commit 53c8c684 authored by Tobias Thierer's avatar Tobias Thierer
Browse files

Document incorrect LinkedHashMap Spliterator ordering in Android N.

Note that in Android N, the Spliterators for LinkedHashMap's
Collection Views did not report the SUBSIZED characteristic;
the Spliterators.spliterator(collection, int) call in the
suggested code snippet implicitly adds that characteristic.

This means that a Spliterator obtained via the suggested code
snippet reports not only a different order but also different
characteristics from the LinkedHashMap's native iterators.
Few applications will care about this subtle difference, and
the new behavior seems to make more sense; therefore, the
documentation does not call out this aspect.

The latest version of LinkedHashMap in AOSP (since [1])
implements its Spliterators via Spliterators.spliterator(),
which means that they do report the SUBSIZED characteristic,
just like the ones obtained via the code snippet in the
documentation added by this CL. Regression tests for the
reported characteristics of these Spliterators will be
submitted to AOSP in a separate CL.

[1] http://r.android.com/255655 (2016-08-16)

Bug: 33945212
Test: make
Test: Verified that the bug exists via guava-testlib-21.0-rc2, code
      inspection and via a small new (unsubmitted) test.
Test: Verified via a small new test (unsubmitted) that the code
      snippets given in the documentation produce the correct
      iteration order.
Test: Verified via a small new test (unsubmitted) that LHM's
      Spliterators do not report SUBSIZED before this CL, but
      that the Spliterators obtained via the suggested
      workaround do. Tested that the characteristics reported
      by the Spliterators obtained via the workaround code
      match those from LHM in the latest version of AOSP.

Change-Id: Ia959b54765df64b27367ce45aedce3fb1eda477a
parent 5ba882bb
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment