https://www.jianshu.com/p/7b9ecc0d6529

http://xinyiworld.top/wordpress_it/?p=13945的startVM方法开始分析:

1172     /* start the virtual machine */
1173     JniInvocation jni_invocation;
1174     jni_invocation.Init(NULL);
1175     JNIEnv* env;
1176     if (startVm(&mJavaVM, &env, zygote) != 0) {
1177         return;
1178     }

JniInvocation类

源码位置:libnativehelper/include/nativehelper/JniInvocation.h
方法实现类:libnativehelper/JniInvocation.cpp

 39 class JniInvocation final {
 40  public:
 41   JniInvocation() {
        //创建JniInvocationImpl实例
 42     impl_ = JniInvocationCreate();
 43   }
 44 
 45   ~JniInvocation() {
 46     JniInvocationDestroy(impl_);
 47   }
 48 
 49   // Initialize JNI invocation API. library should specifiy a valid
 50   // shared library for opening via dlopen providing a JNI invocation
 51   // implementation, or null to allow defaulting via
 52   // persist.sys.dalvik.vm.lib.
 53   bool Init(const char* library) {
 54     return JniInvocationInit(impl_, library) != 0;
 55   }
        ...
    }

→JniInvocationInit
实现位于libnativehelper/JniInvocation.cpp

308 MODULE_API int JniInvocationInit(JniInvocationImpl* instance, const char* library) {
309   return instance->Init(library) ? 1 : 0;
310 }

根据源码可知,最终instance->Init是加载了libart.so库。

jvm的启动

http://xinyiworld.top/wordpress_it/?p=13945


0 条评论

发表回复

您的电子邮箱地址不会被公开。