[Java] Handle nullable arrays
[ldk-java] / src / main / java / org / ldk / structs / NodeAnnouncement.java
index 7168cde2fe9121ff110beeb74ec13a958826a857..e93443e8c0418bb730d99bdb48768fc6ad18525d 100644 (file)
@@ -45,8 +45,8 @@ public class NodeAnnouncement extends CommonBase {
                long ret = bindings.NodeAnnouncement_get_contents(this.ptr);
                Reference.reachabilityFence(this);
                if (ret >= 0 && ret <= 4096) { return null; }
-               UnsignedNodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new UnsignedNodeAnnouncement(null, ret); }
-               ret_hu_conv.ptrs_to.add(this);
+               org.ldk.structs.UnsignedNodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UnsignedNodeAnnouncement(null, ret); }
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
                return ret_hu_conv;
        }
 
@@ -54,21 +54,23 @@ public class NodeAnnouncement extends CommonBase {
         * The actual content of the announcement
         */
        public void set_contents(UnsignedNodeAnnouncement val) {
-               bindings.NodeAnnouncement_set_contents(this.ptr, val == null ? 0 : val.ptr & ~1);
+               bindings.NodeAnnouncement_set_contents(this.ptr, val == null ? 0 : val.ptr);
                Reference.reachabilityFence(this);
                Reference.reachabilityFence(val);
+               if (this != null) { this.ptrs_to.add(val); };
        }
 
        /**
         * Constructs a new NodeAnnouncement given each field
         */
        public static NodeAnnouncement of(byte[] signature_arg, UnsignedNodeAnnouncement contents_arg) {
-               long ret = bindings.NodeAnnouncement_new(InternalUtils.check_arr_len(signature_arg, 64), contents_arg == null ? 0 : contents_arg.ptr & ~1);
+               long ret = bindings.NodeAnnouncement_new(InternalUtils.check_arr_len(signature_arg, 64), contents_arg == null ? 0 : contents_arg.ptr);
                Reference.reachabilityFence(signature_arg);
                Reference.reachabilityFence(contents_arg);
                if (ret >= 0 && ret <= 4096) { return null; }
-               NodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeAnnouncement(null, ret); }
-               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               org.ldk.structs.NodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAnnouncement(null, ret); }
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(contents_arg); };
                return ret_hu_conv;
        }
 
@@ -85,8 +87,8 @@ public class NodeAnnouncement extends CommonBase {
                long ret = bindings.NodeAnnouncement_clone(this.ptr);
                Reference.reachabilityFence(this);
                if (ret >= 0 && ret <= 4096) { return null; }
-               NodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeAnnouncement(null, ret); }
-               ret_hu_conv.ptrs_to.add(this);
+               org.ldk.structs.NodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAnnouncement(null, ret); }
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
                return ret_hu_conv;
        }