diff --git a/lsplant/src/main/jni/include/utils/jni_helper.hpp b/lsplant/src/main/jni/include/utils/jni_helper.hpp index 89284cd..1bca68c 100644 --- a/lsplant/src/main/jni/include/utils/jni_helper.hpp +++ b/lsplant/src/main/jni/include/utils/jni_helper.hpp @@ -1057,6 +1057,18 @@ public: return *this; } + template + JObjectArrayElement &operator=(ScopedLocalRef &&s) { + reset(s.release()); + return *this; + } + + template + JObjectArrayElement &operator=(ScopedLocalRef &s) { + reset(s.clone()); + return *this; + } + JObjectArrayElement &operator=(jobject s) { reset(env_->NewLocalRef(s)); return *this; @@ -1215,9 +1227,7 @@ public: jobjectArray get() const { return local_ref_; } JObjectArrayElement operator[](size_t index) { - return JObjectArrayElement( - env_, local_ref_, index, - JNI_SafeInvoke(env_, &JNIEnv::GetObjectArrayElement, local_ref_, index)); + return JObjectArrayElement(env_, local_ref_, index, size_); } const ScopedLocalRef operator[](size_t index) const {