From bde874c1e7edc655f3ef6530255017306f905ac9 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 28 Apr 2023 16:43:13 +0300 Subject: [PATCH] Fix init_jni_vars for abstract classes. --- td/generate/tl_writer_jni_cpp.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/td/generate/tl_writer_jni_cpp.cpp b/td/generate/tl_writer_jni_cpp.cpp index 472cb728d..cc531f54d 100644 --- a/td/generate/tl_writer_jni_cpp.cpp +++ b/td/generate/tl_writer_jni_cpp.cpp @@ -631,8 +631,13 @@ std::string TD_TL_writer_jni_cpp::gen_additional_proxy_function_begin(const std: "void " + class_name + "::" + function_name + "(JNIEnv *env) {\n" - " Class = jni::get_jclass(env, " + - gen_java_class_name(class_name) + ");\n"; + " static bool is_inited = [&] {\n" + " Class = jni::get_jclass(env, " + + gen_java_class_name(class_name) + + ");\n" + " return true;\n" + " }();\n" + " (void)is_inited;\n"; } std::string TD_TL_writer_jni_cpp::gen_additional_proxy_function_case(const std::string &function_name,