OSDN Git Service

Preserve order of shared library files
authorPaul Duffin <paulduffin@google.com>
Mon, 2 Oct 2017 09:23:25 +0000 (10:23 +0100)
committerPaul Duffin <paulduffin@google.com>
Thu, 5 Oct 2017 09:03:04 +0000 (10:03 +0100)
commitee405a2cfd597848e1e7521089de9b852f4f88bb
tree15829df618010bcf2206440f3a5c6289719b0e6e
parentaff38adc4346fbb37843d25b6f27bf0d7492990c
Preserve order of shared library files

Shared libraries are stored in a list so order is preserved. However,
when they are resolved to files, e.g. for use as a class path the
file names are added to an ArraySet which loses the order. Presumably
they are added to a Set to eliminate duplicates. This switches to a
LinkedHashSet which will preserve the order in which the files are
added while still avoiding duplicates.

It is possible that this could cause app compatibility issues as the
order in which shared libraries is being added is changing. Problems can
only arise if two libraries whose order changes have duplicate classes
and/or resources. In that case the app was only working by luck, as the
order provided by ArraySet is based on the numerical order of hash
codes.

This was found while investigating performance regressions in
GoogleDialer, unfortunately it does not fix the regressions.

Bug: 65552462
Test: flash -w and systrace GoogleDialer to ensure correct order
Change-Id: Ia01ce4821fa53e4785716b72c4f87a0b0ab4dcc8
services/core/java/com/android/server/pm/PackageManagerService.java