From: Matt Corallo Date: Sun, 12 Dec 2021 18:44:34 +0000 (+0000) Subject: Use the same FindClass argument for Android and regular Java X-Git-Tag: v0.0.104.0^2~8 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=a0760b79ab3365b9fa668006330aaa5bb456f824;p=ldk-java 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. --- 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