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(env != nullptr);
|
||||||
assert(name != nullptr);
|
assert(name != nullptr);
|
||||||
|
|
||||||
jclass cls = env->FindClass(name);
|
const Java::Class cls{env, env->FindClass(name)};
|
||||||
assert(cls != nullptr);
|
assert(cls != nullptr);
|
||||||
|
|
||||||
Set(env, cls);
|
Set(env, cls);
|
||||||
env->DeleteLocalRef(cls);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FindOptional(JNIEnv *env, const char *name) noexcept {
|
bool FindOptional(JNIEnv *env, const char *name) noexcept {
|
||||||
assert(env != nullptr);
|
assert(env != nullptr);
|
||||||
assert(name != nullptr);
|
assert(name != nullptr);
|
||||||
|
|
||||||
jclass cls = env->FindClass(name);
|
const Java::Class cls{env, env->FindClass(name)};
|
||||||
if (DiscardException(env))
|
if (DiscardException(env))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Set(env, cls);
|
Set(env, cls);
|
||||||
env->DeleteLocalRef(cls);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue