Refactor ClassLinker & ImageWriter to use a common resolution routine

ImageWriter prepopulates DexCaches of an app image, but does resolution
directly on mirror::Class rather than going through the class linker
where hidden API checks happen. This patch removes the duplicate code.

Similarly, ClassLinker contains multiple methods for resolving methods
and fields. Consolidate these into three common routines:
- FindResolvedMethod
- FindResolvedField
- FindResolvedFieldJLS

The CL also passes the correct class loader to
ImageWriter::PruneAndPreloadDexCache because it would trip a DCHECK
in class linker.

Bug: 78548674
Test: art/test.py
Merged-In: I12e383290945d2f44b209c32e8a7617533d86063
Change-Id: I12e383290945d2f44b209c32e8a7617533d86063
(cherry picked from commit 1ab0fa89aed1100a3e6b631cb188db1d759b1efc)
3 files changed