java_hu_struct += "\tprotected void finalize() throws Throwable {\n"
java_hu_struct += "\t\tif (ptr != 0) { bindings." + struct_name.replace("LDK","") + "_free(ptr); } super.finalize();\n"
java_hu_struct += "\t}\n\n"
+ java_hu_struct += "\tprotected void force_free() {\n" # Used by NioPeerHandler
+ java_hu_struct += "\t\tif (ptr != 0) { bindings." + struct_name.replace("LDK","") + "_free(ptr); ptr = 0; }\n"
+ java_hu_struct += "\t}\n\n"
java_hu_struct += "\tstatic " + human_ty + " constr_from_ptr(long ptr) {\n"
java_hu_struct += "\t\tif (bindings." + struct_name.replace("LDK", "") + "_is_ok(ptr)) {\n"
java_hu_struct += "\t\t\treturn new " + human_ty + "_OK(null, ptr);\n"