Only look for method optimization annotations in the bootstrap class loader.

When checking for an optimization annotation (FastNative or
CriticalNative) on a method, do not resolve the method's annotations'
classes as a side effect -- instead, look them up in the bootstrap
class loader's resolved types. This is to prevent exceptions from being
thrown (during class resolution) in JNI transitions.

This change does not affect annotation lookup rules in the context of
reflection.

(cherry-picked from commit 35e42f0ab3b70203038fe037ee50d39e2d37af9a)

Test: art/test/testrunner/testrunner.py -t 656-annotation-lookup-generic-jni
Bug: 38454151
Bug: 34659969
Change-Id: Ie6b8b30b96a08baa629c449e3803a031515508d1
(cherry picked from commit 2ed6cce6fcfd031b0f9d83111f01b6b48ead1a32)
5 files changed