diff options
author | Sven Gothel <[email protected]> | 2022-05-04 19:02:15 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2022-05-04 19:02:15 +0200 |
commit | c09cfe41013dc1167c8e98cba919402b2f77e7fd (patch) | |
tree | a0f7ed60ae96b834971b83efcfa07fc4868f1a7b /include/jau/jni | |
parent | 43a103bc3ce8782c30e1603d731f97e03f5be275 (diff) |
JavaGlobalObj: Add explicit ctor w/ pre-existing JNIGlobalRef; Fix getJavaObject(): Return instance, add const ref variant if so desired
Diffstat (limited to 'include/jau/jni')
-rw-r--r-- | include/jau/jni/helper_jni.hpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/include/jau/jni/helper_jni.hpp b/include/jau/jni/helper_jni.hpp index 6f36863..78485a6 100644 --- a/include/jau/jni/helper_jni.hpp +++ b/include/jau/jni/helper_jni.hpp @@ -184,6 +184,9 @@ namespace jau { JavaGlobalObj(jobject obj, jmethodID mNotifyDeleted_) noexcept : javaObjectRef(obj), mNotifyDeleted(mNotifyDeleted_) { } + JavaGlobalObj(JNIGlobalRef obj, jmethodID mNotifyDeleted_) noexcept + : javaObjectRef(obj), mNotifyDeleted(mNotifyDeleted_) { } + JavaGlobalObj(const JavaGlobalObj &o) noexcept = default; JavaGlobalObj(JavaGlobalObj &&o) noexcept = default; JavaGlobalObj& operator=(const JavaGlobalObj &o) noexcept = default; @@ -196,7 +199,8 @@ namespace jau { return "JavaGlobalObj["+to_hexstring(ref)+"]"; } - JNIGlobalRef & getJavaObject() noexcept { return javaObjectRef; } + const JNIGlobalRef & getJavaObject() const noexcept { return javaObjectRef; } + JNIGlobalRef getJavaObject() noexcept { return javaObjectRef; } /* Provides access to the stored GlobalRef as an jobject. */ jobject getObject() const noexcept { return javaObjectRef.getObject(); } |