java/Class: use Java::LocalObject
This eliminates all but one DeleteLocalRef() call.
This commit is contained in:
parent
31f7fede30
commit
c9a9248c9f
@ -58,23 +58,21 @@ public:
|
||||
assert(env != nullptr);
|
||||
assert(name != nullptr);
|
||||
|
||||
jclass cls = env->FindClass(name);
|
||||
const Java::Class cls{env, env->FindClass(name)};
|
||||
assert(cls != nullptr);
|
||||
|
||||
Set(env, cls);
|
||||
env->DeleteLocalRef(cls);
|
||||
}
|
||||
|
||||
bool FindOptional(JNIEnv *env, const char *name) noexcept {
|
||||
assert(env != nullptr);
|
||||
assert(name != nullptr);
|
||||
|
||||
jclass cls = env->FindClass(name);
|
||||
const Java::Class cls{env, env->FindClass(name)};
|
||||
if (DiscardException(env))
|
||||
return false;
|
||||
|
||||
Set(env, cls);
|
||||
env->DeleteLocalRef(cls);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user