From c9a9248c9f3d5d5c2bdfa0e11f3f7891443d9465 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 23 Jul 2021 18:00:33 +0200 Subject: [PATCH] java/Class: use Java::LocalObject This eliminates all but one DeleteLocalRef() call. --- src/java/Class.hxx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/java/Class.hxx b/src/java/Class.hxx index ab8a4e1a8..f7575efe5 100644 --- a/src/java/Class.hxx +++ b/src/java/Class.hxx @@ -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; } };