From 95be164556de14834c2040ac7bea1632b63e5764 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Mon, 4 Jan 2016 13:24:48 -0800 Subject: [PATCH] libnativehelper.so was there before JniInvocation. --- Java/Execute.cpp | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/Java/Execute.cpp b/Java/Execute.cpp index 471f71c..f450a5d 100644 --- a/Java/Execute.cpp +++ b/Java/Execute.cpp @@ -1391,22 +1391,24 @@ static JNIEnv *GetJNI_(JSContextRef context) { dlset(JniInvocation$Init, "_ZN13JniInvocation4InitEPKc", libnativehelper); dlset(JniInvocation$finalize, "_ZN13JniInvocationD1Ev", libnativehelper); - // XXX: we should attach a pool to the VM itself and deallocate this there - //auto invocation(pool.calloc(1, 1024)); - //_assert(JniInvocation$finalize != NULL); - //pool.atexit(reinterpret_cast(JniInvocation$finalize), invocation); - - auto invocation(static_cast(calloc(1, 1024))); - - _assert(JniInvocation$$init$ != NULL); - JniInvocation$$init$(invocation); - - _assert(JniInvocation$Init != NULL); - JniInvocation$Init(invocation, NULL); - - dlset($JNI_GetCreatedJavaVMs, "JNI_GetCreatedJavaVMs", libnativehelper); - if (JNIEnv *jni = CYGetCreatedJava($JNI_GetCreatedJavaVMs)) - return jni; + if (JniInvocation$$init$ == NULL) + dlclose(libnativehelper); + else { + // XXX: we should attach a pool to the VM itself and deallocate this there + //auto invocation(pool.calloc(1, 1024)); + //_assert(JniInvocation$finalize != NULL); + //pool.atexit(reinterpret_cast(JniInvocation$finalize), invocation); + + auto invocation(static_cast(calloc(1, 1024))); + JniInvocation$$init$(invocation); + + _assert(JniInvocation$Init != NULL); + JniInvocation$Init(invocation, NULL); + + dlset($JNI_GetCreatedJavaVMs, "JNI_GetCreatedJavaVMs", libnativehelper); + if (JNIEnv *jni = CYGetCreatedJava($JNI_GetCreatedJavaVMs)) + return jni; + } } if (void *libandroid_runtime = dlopen("libandroid_runtime.so", RTLD_LAZY | RTLD_GLOBAL)) { -- 2.45.2