From 93954d08dd2511af0cfc1fb3d6fc9109dbe9b69d Mon Sep 17 00:00:00 2001 From: Csaba Szigeti Date: Tue, 30 Oct 2018 12:36:00 +0100 Subject: [PATCH 1/2] Add the ability to get the JavaVM which was registered in the onload for e.g. forwarding to other libraries --- support-lib/jni/djinni_support.cpp | 6 ++++++ support-lib/jni/djinni_support.hpp | 7 +++++++ 2 files changed, 13 insertions(+) mode change 100644 => 100755 support-lib/jni/djinni_support.cpp mode change 100644 => 100755 support-lib/jni/djinni_support.hpp diff --git a/support-lib/jni/djinni_support.cpp b/support-lib/jni/djinni_support.cpp old mode 100644 new mode 100755 index 142b9e220..77e2f0042 --- a/support-lib/jni/djinni_support.cpp +++ b/support-lib/jni/djinni_support.cpp @@ -69,6 +69,10 @@ void jniShutdown() { g_cachedJVM = nullptr; } +JavaVM * jniGetVM() { + return g_cachedJVM; +} + JNIEnv * jniGetThreadEnv() { assert(g_cachedJVM); JNIEnv * env = nullptr; @@ -594,6 +598,8 @@ void jniDefaultSetPendingFromCurrentImpl(JNIEnv * env) { return; } catch (const std::exception & e) { env->ThrowNew(env->FindClass("java/lang/RuntimeException"), e.what()); + } catch(...) { + std::terminate(); } } diff --git a/support-lib/jni/djinni_support.hpp b/support-lib/jni/djinni_support.hpp old mode 100644 new mode 100755 index ddae5049d..706d3dd6f --- a/support-lib/jni/djinni_support.hpp +++ b/support-lib/jni/djinni_support.hpp @@ -42,6 +42,13 @@ namespace djinni { void jniInit(JavaVM * jvm); void jniShutdown(); +/* + * Get the JavaVM which was registered in the onload for e.g. forwarding to other libraries + * + */ + +JavaVM * jniGetVM(); + /* * Get the JNIEnv for the invoking thread. Should only be called on Java-created threads. */ From f28d35c15be628c06c55dda25d8a99f5a27940b4 Mon Sep 17 00:00:00 2001 From: Csaba Szigeti Date: Fri, 2 Nov 2018 09:37:01 +0100 Subject: [PATCH 2/2] Update support-lib/jni/djinni_support.cpp Revert unnecessary change --- support-lib/jni/djinni_support.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/support-lib/jni/djinni_support.cpp b/support-lib/jni/djinni_support.cpp index 77e2f0042..598d293ec 100755 --- a/support-lib/jni/djinni_support.cpp +++ b/support-lib/jni/djinni_support.cpp @@ -598,8 +598,6 @@ void jniDefaultSetPendingFromCurrentImpl(JNIEnv * env) { return; } catch (const std::exception & e) { env->ThrowNew(env->FindClass("java/lang/RuntimeException"), e.what()); - } catch(...) { - std::terminate(); } }