Fix redefinition causing corrupt j.l.r.Field objects

During (non-structural) redefinition we change the dex-field-indexs of
all the ArtField's of the class being redefined. These ids are used by
the java/lang/reflect/Field class to avoid having to store a pointer
to the ArtField. This meant that when a class was redefined any
existing j.l.r.Field objects pointing to its fields are rendered
invalid, due to the dex_field_index no longer being present on the
class.

To fix this we simply walk the heap during class redefinition and
update any j.l.r.Field objects of the redefined class that we find.

Test: ./test.py --host
Bug: 147310999
Bug: 147338896
Change-Id: I3b038b4e669f8b7b4e804238248b4d03780ce2ca
8 files changed