Skip to content

Commit

Permalink
Improve JniLocalReferenceManager class (#31813)
Browse files Browse the repository at this point in the history
  • Loading branch information
yufengwangca authored and pull[bot] committed Mar 11, 2024
1 parent 71f0c7d commit 3269968
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/lib/support/JniTypeWrappers.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,14 @@ class JniGlobalRefWrapper
class JniLocalReferenceManager
{
public:
JniLocalReferenceManager(JNIEnv * env) : mEnv(env)
explicit JniLocalReferenceManager(JNIEnv * env) : mEnv(env)
{
if (mEnv->PushLocalFrame(JNI_LOCAL_REF_COUNT) == 0)
{
mlocalFramePushed = true;
}
}

~JniLocalReferenceManager()
{
if (mlocalFramePushed)
Expand All @@ -202,8 +203,12 @@ class JniLocalReferenceManager
}
}

// Delete copy constructor and copy assignment operator
JniLocalReferenceManager(const JniLocalReferenceManager &) = delete;
JniLocalReferenceManager & operator=(const JniLocalReferenceManager &) = delete;

private:
JNIEnv * mEnv = nullptr;
JNIEnv * const mEnv;
bool mlocalFramePushed = false;
};

Expand Down

0 comments on commit 3269968

Please sign in to comment.