Skip to content

Commit

Permalink
[Java] Ensure bindings statics run before enums call native code
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBlueMatt committed Mar 13, 2024
1 parent 6ab8c07 commit 6ea3392
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion java_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def __init__(self, DEBUG: bool, target: Target, **kwargs):
// Fetching the LDK versions from C also checks that the header and binaries match
System.err.println("Loaded LDK-Java Bindings " + version.get_ldk_java_bindings_version() + " with LDK " + get_ldk_version() + " and LDK-C-Bindings " + get_ldk_c_bindings_version());
}
public static void run_statics() { /* Useful to force the statics to run */ }
static native void init(java.lang.Class c);
static native void init_class_cache();
static native String get_lib_version_string();
Expand Down Expand Up @@ -861,7 +862,7 @@ def native_c_unitary_enum_map(self, struct_name, variants, enum_doc_comment):
out_c = out_c + "\t\tcase %d: return %s;\n" % (ord_v, var)
ord_v = ord_v + 1
out_java_enum = out_java_enum + "\t; static native void init();\n"
out_java_enum = out_java_enum + "\tstatic { init(); }\n"
out_java_enum = out_java_enum + "\tstatic { org.ldk.impl.bindings.run_statics(); init(); }\n"
out_java_enum = out_java_enum + "}"
out_java = out_java + "\tstatic { " + struct_name + ".values(); /* Force enum statics to run */ }\n"
out_c += "\t}\n"
Expand Down

0 comments on commit 6ea3392

Please sign in to comment.