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
Change-Id: I12e383290945d2f44b209c32e8a7617533d86063
3 files changed