Use AutoCloseable for structs named Locked*
[ldk-java] / src / main / java / org / ldk / structs / RevokeAndACK.java
index 514ded4babd564fb71f690b0d878dedd89aacc33..1c7a4a039c7d1b0f6bf6a76bef8ddb0358b71e18 100644 (file)
@@ -7,44 +7,45 @@ public class RevokeAndACK extends CommonBase {
        RevokeAndACK(Object _dummy, long ptr) { super(ptr); }
        @Override @SuppressWarnings("deprecation")
        protected void finalize() throws Throwable {
-               bindings.RevokeAndACK_free(ptr); super.finalize();
+               super.finalize();
+               bindings.RevokeAndACK_free(ptr);
        }
 
        public RevokeAndACK(RevokeAndACK orig) {
-               super(bindings.RevokeAndACK_clone(orig.ptr & ~1));
+               super(bindings.RevokeAndACK_clone(orig == null ? 0 : orig.ptr & ~1));
                this.ptrs_to.add(orig);
        }
 
        public byte[] get_channel_id(RevokeAndACK this_ptr) {
-               byte[] ret = bindings.RevokeAndACK_get_channel_id(this_ptr.ptr & ~1);
+               byte[] ret = bindings.RevokeAndACK_get_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1);
                this.ptrs_to.add(this_ptr);
                return ret;
        }
 
        public void set_channel_id(RevokeAndACK this_ptr, byte[] val) {
-               bindings.RevokeAndACK_set_channel_id(this_ptr.ptr & ~1, val);
+               bindings.RevokeAndACK_set_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val);
                this.ptrs_to.add(this_ptr);
        }
 
        public byte[] get_per_commitment_secret(RevokeAndACK this_ptr) {
-               byte[] ret = bindings.RevokeAndACK_get_per_commitment_secret(this_ptr.ptr & ~1);
+               byte[] ret = bindings.RevokeAndACK_get_per_commitment_secret(this_ptr == null ? 0 : this_ptr.ptr & ~1);
                this.ptrs_to.add(this_ptr);
                return ret;
        }
 
        public void set_per_commitment_secret(RevokeAndACK this_ptr, byte[] val) {
-               bindings.RevokeAndACK_set_per_commitment_secret(this_ptr.ptr & ~1, val);
+               bindings.RevokeAndACK_set_per_commitment_secret(this_ptr == null ? 0 : this_ptr.ptr & ~1, val);
                this.ptrs_to.add(this_ptr);
        }
 
        public byte[] get_next_per_commitment_point(RevokeAndACK this_ptr) {
-               byte[] ret = bindings.RevokeAndACK_get_next_per_commitment_point(this_ptr.ptr & ~1);
+               byte[] ret = bindings.RevokeAndACK_get_next_per_commitment_point(this_ptr == null ? 0 : this_ptr.ptr & ~1);
                this.ptrs_to.add(this_ptr);
                return ret;
        }
 
        public void set_next_per_commitment_point(RevokeAndACK this_ptr, byte[] val) {
-               bindings.RevokeAndACK_set_next_per_commitment_point(this_ptr.ptr & ~1, val);
+               bindings.RevokeAndACK_set_next_per_commitment_point(this_ptr == null ? 0 : this_ptr.ptr & ~1, val);
                this.ptrs_to.add(this_ptr);
        }