Use AutoCloseable for structs named Locked*
[ldk-java] / src / main / java / org / ldk / structs / UpdateFailHTLC.java
index 4243363881c6fb6403ad69f61f4760dd563d94c7..50147508fdcd19a2fc6f618437ef4c2f19f93aff 100644 (file)
@@ -7,36 +7,40 @@ public class UpdateFailHTLC extends CommonBase {
        UpdateFailHTLC(Object _dummy, long ptr) { super(ptr); }
        @Override @SuppressWarnings("deprecation")
        protected void finalize() throws Throwable {
-               bindings.UpdateFailHTLC_free(ptr); super.finalize();
+               super.finalize();
+               bindings.UpdateFailHTLC_free(ptr);
        }
 
        public UpdateFailHTLC(UpdateFailHTLC orig) {
-               super(bindings.UpdateFailHTLC_clone(orig.ptr & ~1));
+               super(bindings.UpdateFailHTLC_clone(orig == null ? 0 : orig.ptr & ~1));
                this.ptrs_to.add(orig);
        }
 
        public byte[] get_channel_id(UpdateFailHTLC this_ptr) {
-               byte[] ret = bindings.UpdateFailHTLC_get_channel_id(this_ptr.ptr & ~1);
+               byte[] ret = bindings.UpdateFailHTLC_get_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1);
                this.ptrs_to.add(this_ptr);
                return ret;
        }
 
        public void set_channel_id(UpdateFailHTLC this_ptr, byte[] val) {
-               bindings.UpdateFailHTLC_set_channel_id(this_ptr.ptr & ~1, val);
+               bindings.UpdateFailHTLC_set_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val);
                this.ptrs_to.add(this_ptr);
        }
 
        public long get_htlc_id(UpdateFailHTLC this_ptr) {
-               long ret = bindings.UpdateFailHTLC_get_htlc_id(this_ptr.ptr & ~1);
+               long ret = bindings.UpdateFailHTLC_get_htlc_id(this_ptr == null ? 0 : this_ptr.ptr & ~1);
                this.ptrs_to.add(this_ptr);
                return ret;
        }
 
        public void set_htlc_id(UpdateFailHTLC this_ptr, long val) {
-               bindings.UpdateFailHTLC_set_htlc_id(this_ptr.ptr & ~1, val);
+               bindings.UpdateFailHTLC_set_htlc_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val);
                this.ptrs_to.add(this_ptr);
        }
 
        // Skipped UpdateFailHTLC_write
-       // Skipped UpdateFailHTLC_read
+       public UpdateFailHTLC(byte[] ser) {
+               super(bindings.UpdateFailHTLC_read(ser));
+       }
+
 }