ArtMethod::RegisterNatives
RegisterNatives函数是JNI动态注册时所用到的函数,其定义在结构体ArtMethod当中,其在Android10的具体实现是在/art/runtime/jni/jni_internal.cc
。
RegisterNatives注册流程
static jint RegisterNatives(JNIEnv* env, jclass java_class, const JNINativeMethod* methods, jint method_count)
=>
const void* ArtMethod::RegisterNative(const void* native_method)
=>
void RuntimeCallbacks::RegisterNativeMethod(ArtMethod* method, const void* in_cur_method, /out/void** new_method)
=>
void SetEntryPointFromJni(const void* entrypoint)
=>
template
ALWAYS_INLINE void SetEntryPointFromJniPtrSize(const void* entrypoint, PointerSize pointer_size)
=>
template
ALWAYS_INLINE void SetDataPtrSize(const void* data, PointerSize pointer_size)
=>
template
ALWAYS_INLINE void SetNativePointer(MemberOffset offset, T new_value, PointerSize pointer_size)