Refactor enforcement of hidden API policy when linking

Hidden API enforcement when linking was sub-optimal for two reasons:
a) it was based on Class::CanAccessMember and would throw
IllegalAccessError instead of NoSuchMethodError/NoSuchFieldError, and
b) no warnings were printed in the code path.

This patch moves the checks into ClassLinker's resolution routines and
uses a code path which prints warning.

Bug: 64382372
Test: art/test.py -r -t 674-hiddenapi
Change-Id: I8a0fbdca58ce5803c1588b644a3e627a0a9a6504
(cherry picked from commit 8ce3bfaf1da2139a70b67e6b53c0110489801d40)
10 files changed