From a0760b79ab3365b9fa668006330aaa5bb456f824 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sun, 12 Dec 2021 18:44:34 +0000 Subject: [PATCH] Use the same FindClass argument for Android and regular Java Its unclear whether the android variant (no L prefix, ; suffix) was ever tested on normal Java or not, but the existing code generates a large volumes of warnings on OpenJDK 11 like: WARNING in native method: JNI FindClass received a bad class descriptor "Lorg/ldk/impl/bindings$LDKEvent$PaymentReceived;". A correct class descriptor has no leading "L" or trailing ";". Incorrect descriptors will not be accepted in future releases. --- java_strings.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/java_strings.py b/java_strings.py index 5ff98d9d..95c65ce7 100644 --- a/java_strings.py +++ b/java_strings.py @@ -681,14 +681,11 @@ import javax.annotation.Nullable; out_c = out_c + "static jmethodID " + struct_name + "_" + var + "_meth = NULL;\n" out_c = out_c + self.c_fn_ty_pfx + "void JNICALL Java_org_ldk_impl_bindings_00024" + struct_name.replace("_", "_1") + "_init (" + self.c_fn_args_pfx + ") {\n" for var_name in variants: - out_c = out_c + "\t" + struct_name + "_" + var_name + "_class =\n" - if self.target == Target.ANDROID: - out_c = out_c + "\t\t(*env)->NewGlobalRef(env, (*env)->FindClass(env, \"org/ldk/impl/bindings$" + struct_name + "$" + var_name + "\"));\n" - else: - out_c = out_c + "\t\t(*env)->NewGlobalRef(env, (*env)->FindClass(env, \"Lorg/ldk/impl/bindings$" + struct_name + "$" + var_name + ";\"));\n" - out_c = out_c + "\tCHECK(" + struct_name + "_" + var_name + "_class != NULL);\n" - out_c = out_c + "\t" + struct_name + "_" + var_name + "_meth = (*env)->GetMethodID(env, " + struct_name + "_" + var_name + "_class, \"\", \"(" + init_meth_jty_strs[var_name] + ")V\");\n" - out_c = out_c + "\tCHECK(" + struct_name + "_" + var_name + "_meth != NULL);\n" + out_c += "\t" + struct_name + "_" + var_name + "_class =\n" + out_c += "\t\t(*env)->NewGlobalRef(env, (*env)->FindClass(env, \"org/ldk/impl/bindings$" + struct_name + "$" + var_name + "\"));\n" + out_c += "\tCHECK(" + struct_name + "_" + var_name + "_class != NULL);\n" + out_c += "\t" + struct_name + "_" + var_name + "_meth = (*env)->GetMethodID(env, " + struct_name + "_" + var_name + "_class, \"\", \"(" + init_meth_jty_strs[var_name] + ")V\");\n" + out_c += "\tCHECK(" + struct_name + "_" + var_name + "_meth != NULL);\n" out_c = out_c + "}\n" return out_c -- 2.39.5