-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
4 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
* JMI: JNI Modern Interface | ||
* Copyright (C) 2016-2023 Wang Bin - [email protected] | ||
* Copyright (C) 2016-2024 Wang Bin - [email protected] | ||
* https://github.com/wang-bin/JMI | ||
* MIT License | ||
*/ | ||
|
@@ -167,7 +167,7 @@ class JObject : public ClassTag | |
operator jclass() const { return classId();} | ||
jobject id() const { return oid_; } | ||
explicit operator bool() const { return !!oid_;} | ||
string error() const {return error_;} | ||
const string& error() const {return error_;} | ||
JObject& reset(jobject obj = nullptr, JNIEnv *env = nullptr); | ||
|
||
template<typename... Args> | ||
|
@@ -275,7 +275,7 @@ class JObject : public ClassTag | |
} | ||
private: | ||
static jclass classId(JNIEnv* env = nullptr); | ||
JObject& setError(string&& s) const { | ||
JObject& setError(const string& s) const { | ||
error_ = std::move(s); | ||
return *const_cast<JObject*>(this); | ||
} | ||
|
@@ -980,8 +980,7 @@ JObject<CTag>& JObject<CTag>::reset(jobject obj, JNIEnv *env) { | |
if (!env) | ||
return setError("Invalid JNIEnv"); | ||
} | ||
if (oid_) | ||
env->DeleteGlobalRef(oid_); | ||
env->DeleteGlobalRef(oid_); // can be null | ||
oid_ = nullptr; | ||
if (obj) { | ||
oid_ = env->NewGlobalRef(obj); | ||
|