hiddenapi: Fix class hierarchy traversal

`hiddenapi` builds and traverses the class hierarchy, visiting all
class members that methods/fields in stubs may resolve to.

The algorithm wouldn't work when:
* an interface declares a method which is in stubs, and
* a class implements the interface by inheriting the method from its
  superclass; neither the class nor its superclass are in stubs.
The problem was that once a matching method was found, only subclasses
would be traversed. In this case, the method would be found in the
interface, the class which implements it would be traversed but its
superclass would not.

This patch simplifies the algorithm and partially reverts a performance
optimization which caused the problem. As a result, there is a build
time regression from 5s to 8s.

The patch also adds gtests which test this behaviour. There were no
tests until now because stubs are not present in master-art manifest.
Get around this issue by using the actual core JARs as stubs but test
the behaviour on other classes.

Bug: 122551864
Test: m test-art-host-gtest-hiddenapi_test
Change-Id: I63751c5ef517c8e9d3a157dfbec8de01bd99c2d4
8 files changed