Change LinkedHashMap#removeEldestEntry behaviour.
The move to OpenJDK changed the behaviour of the removeEldestEntry
method in a way that is incompatible with earlier Android versions.
While that behaviour was never documented, we try to be compatible for
now. Future Android releases will probably revert to behaviour that's
closer to the RI.
This is attempt #2. The behaviour of of the previous implementation was
even stranger then expected. removeEldestEntry() was called between
incrementing the size field and actually adding the entry. So any code
that inspected the map during the removeEldestEntry() call would see
a size that's 1 bigger than the actual elements (and the newly added
element would not be in the map yet).
The code to reproduce this in the OpenJDK based implementation is less
than elegant and should be removed for future releases.
(cherry picked from commit 7a0fb3b1203df27e0bb3e5b1ee3346851f9af38d)
2 files changed