]> git.saurik.com Git - cycript.git/commitdiff
libnativehelper.so was there before JniInvocation.
authorJay Freeman (saurik) <saurik@saurik.com>
Mon, 4 Jan 2016 21:24:48 +0000 (13:24 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Mon, 4 Jan 2016 21:24:48 +0000 (13:24 -0800)
Java/Execute.cpp

index 471f71c9d185b7ccf1a39362d1b1a39f57b83bd8..f450a5d6da223a8af7dc73fa2fef7cf5b821cc78 100644 (file)
@@ -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<JniInvocation$>(1, 1024));
-        //_assert(JniInvocation$finalize != NULL);
-        //pool.atexit(reinterpret_cast<void (*)(void *)>(JniInvocation$finalize), invocation);
-
-        auto invocation(static_cast<JniInvocation$ *>(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<JniInvocation$>(1, 1024));
+            //_assert(JniInvocation$finalize != NULL);
+            //pool.atexit(reinterpret_cast<void (*)(void *)>(JniInvocation$finalize), invocation);
+
+            auto invocation(static_cast<JniInvocation$ *>(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)) {