From: Matt Corallo Date: Wed, 14 Oct 2020 00:06:11 +0000 (-0400) Subject: Use AutoCloseable for structs named Locked* X-Git-Tag: v0.0.1~103 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=ad15b3a4dbf3fbc7f08ef22d656bae79e8182008;p=ldk-java Use AutoCloseable for structs named Locked* --- diff --git a/genbindings.py b/genbindings.py index a0d0ab62..f4086f56 100755 --- a/genbindings.py +++ b/genbindings.py @@ -1211,11 +1211,18 @@ class CommonBase { out_java_struct.write("package org.ldk.structs;\n\n") out_java_struct.write("import org.ldk.impl.bindings;\n") out_java_struct.write("import org.ldk.enums.*;\n\n") - out_java_struct.write("public class " + struct_name.replace("LDK","") + " extends CommonBase {\n") + out_java_struct.write("public class " + struct_name.replace("LDK","") + " extends CommonBase") + if struct_name.startswith("LDKLocked"): + out_java_struct.write(" implements AutoCloseable") + out_java_struct.write(" {\n") out_java_struct.write("\t" + struct_name.replace("LDK", "") + "(Object _dummy, long ptr) { super(ptr); }\n") - out_java_struct.write("\t@Override @SuppressWarnings(\"deprecation\")\n") - out_java_struct.write("\tprotected void finalize() throws Throwable {\n") - out_java_struct.write("\t\tbindings." + struct_name.replace("LDK","") + "_free(ptr); super.finalize();\n") + if struct_name.startswith("LDKLocked"): + out_java_struct.write("\t@Override public void close() {\n") + else: + out_java_struct.write("\t@Override @SuppressWarnings(\"deprecation\")\n") + out_java_struct.write("\tprotected void finalize() throws Throwable {\n") + out_java_struct.write("\t\tsuper.finalize();\n") + out_java_struct.write("\t\tbindings." + struct_name.replace("LDK","") + "_free(ptr);\n") out_java_struct.write("\t}\n\n") elif result_contents is not None: result_templ_structs.add(struct_name) diff --git a/src/main/java/org/ldk/structs/AcceptChannel.java b/src/main/java/org/ldk/structs/AcceptChannel.java index e7c4b472..a3c4f0c3 100644 --- a/src/main/java/org/ldk/structs/AcceptChannel.java +++ b/src/main/java/org/ldk/structs/AcceptChannel.java @@ -7,7 +7,8 @@ public class AcceptChannel extends CommonBase { AcceptChannel(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.AcceptChannel_free(ptr); super.finalize(); + super.finalize(); + bindings.AcceptChannel_free(ptr); } public AcceptChannel(AcceptChannel orig) { diff --git a/src/main/java/org/ldk/structs/AnnouncementSignatures.java b/src/main/java/org/ldk/structs/AnnouncementSignatures.java index b4812746..90abb315 100644 --- a/src/main/java/org/ldk/structs/AnnouncementSignatures.java +++ b/src/main/java/org/ldk/structs/AnnouncementSignatures.java @@ -7,7 +7,8 @@ public class AnnouncementSignatures extends CommonBase { AnnouncementSignatures(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.AnnouncementSignatures_free(ptr); super.finalize(); + super.finalize(); + bindings.AnnouncementSignatures_free(ptr); } public AnnouncementSignatures(AnnouncementSignatures orig) { diff --git a/src/main/java/org/ldk/structs/ChainMonitor.java b/src/main/java/org/ldk/structs/ChainMonitor.java index 55a934a2..94e0f36e 100644 --- a/src/main/java/org/ldk/structs/ChainMonitor.java +++ b/src/main/java/org/ldk/structs/ChainMonitor.java @@ -7,7 +7,8 @@ public class ChainMonitor extends CommonBase { ChainMonitor(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.ChainMonitor_free(ptr); super.finalize(); + super.finalize(); + bindings.ChainMonitor_free(ptr); } // Skipped ChainMonitor_block_connected diff --git a/src/main/java/org/ldk/structs/ChannelAnnouncement.java b/src/main/java/org/ldk/structs/ChannelAnnouncement.java index 69c573d8..0b17c7a0 100644 --- a/src/main/java/org/ldk/structs/ChannelAnnouncement.java +++ b/src/main/java/org/ldk/structs/ChannelAnnouncement.java @@ -7,7 +7,8 @@ public class ChannelAnnouncement extends CommonBase { ChannelAnnouncement(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.ChannelAnnouncement_free(ptr); super.finalize(); + super.finalize(); + bindings.ChannelAnnouncement_free(ptr); } public ChannelAnnouncement(ChannelAnnouncement orig) { diff --git a/src/main/java/org/ldk/structs/ChannelConfig.java b/src/main/java/org/ldk/structs/ChannelConfig.java index 7676cae3..fe80bccf 100644 --- a/src/main/java/org/ldk/structs/ChannelConfig.java +++ b/src/main/java/org/ldk/structs/ChannelConfig.java @@ -7,7 +7,8 @@ public class ChannelConfig extends CommonBase { ChannelConfig(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.ChannelConfig_free(ptr); super.finalize(); + super.finalize(); + bindings.ChannelConfig_free(ptr); } public ChannelConfig(ChannelConfig orig) { diff --git a/src/main/java/org/ldk/structs/ChannelDetails.java b/src/main/java/org/ldk/structs/ChannelDetails.java index 35107dd5..677ec972 100644 --- a/src/main/java/org/ldk/structs/ChannelDetails.java +++ b/src/main/java/org/ldk/structs/ChannelDetails.java @@ -7,7 +7,8 @@ public class ChannelDetails extends CommonBase { ChannelDetails(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.ChannelDetails_free(ptr); super.finalize(); + super.finalize(); + bindings.ChannelDetails_free(ptr); } public ChannelDetails(ChannelDetails orig) { diff --git a/src/main/java/org/ldk/structs/ChannelFeatures.java b/src/main/java/org/ldk/structs/ChannelFeatures.java index e697e791..2a21c80d 100644 --- a/src/main/java/org/ldk/structs/ChannelFeatures.java +++ b/src/main/java/org/ldk/structs/ChannelFeatures.java @@ -7,7 +7,8 @@ public class ChannelFeatures extends CommonBase { ChannelFeatures(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.ChannelFeatures_free(ptr); super.finalize(); + super.finalize(); + bindings.ChannelFeatures_free(ptr); } } diff --git a/src/main/java/org/ldk/structs/ChannelHandshakeConfig.java b/src/main/java/org/ldk/structs/ChannelHandshakeConfig.java index f8cea8fd..a543225a 100644 --- a/src/main/java/org/ldk/structs/ChannelHandshakeConfig.java +++ b/src/main/java/org/ldk/structs/ChannelHandshakeConfig.java @@ -7,7 +7,8 @@ public class ChannelHandshakeConfig extends CommonBase { ChannelHandshakeConfig(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.ChannelHandshakeConfig_free(ptr); super.finalize(); + super.finalize(); + bindings.ChannelHandshakeConfig_free(ptr); } public ChannelHandshakeConfig(ChannelHandshakeConfig orig) { diff --git a/src/main/java/org/ldk/structs/ChannelHandshakeLimits.java b/src/main/java/org/ldk/structs/ChannelHandshakeLimits.java index 309e07b1..1df3f8cb 100644 --- a/src/main/java/org/ldk/structs/ChannelHandshakeLimits.java +++ b/src/main/java/org/ldk/structs/ChannelHandshakeLimits.java @@ -7,7 +7,8 @@ public class ChannelHandshakeLimits extends CommonBase { ChannelHandshakeLimits(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.ChannelHandshakeLimits_free(ptr); super.finalize(); + super.finalize(); + bindings.ChannelHandshakeLimits_free(ptr); } public ChannelHandshakeLimits(ChannelHandshakeLimits orig) { diff --git a/src/main/java/org/ldk/structs/ChannelInfo.java b/src/main/java/org/ldk/structs/ChannelInfo.java index b0de8cbe..d5b23cc4 100644 --- a/src/main/java/org/ldk/structs/ChannelInfo.java +++ b/src/main/java/org/ldk/structs/ChannelInfo.java @@ -7,7 +7,8 @@ public class ChannelInfo extends CommonBase { ChannelInfo(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.ChannelInfo_free(ptr); super.finalize(); + super.finalize(); + bindings.ChannelInfo_free(ptr); } public ChannelFeatures get_features(ChannelInfo this_ptr) { diff --git a/src/main/java/org/ldk/structs/ChannelManager.java b/src/main/java/org/ldk/structs/ChannelManager.java index dbf4feda..ec82ff9e 100644 --- a/src/main/java/org/ldk/structs/ChannelManager.java +++ b/src/main/java/org/ldk/structs/ChannelManager.java @@ -7,7 +7,8 @@ public class ChannelManager extends CommonBase { ChannelManager(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.ChannelManager_free(ptr); super.finalize(); + super.finalize(); + bindings.ChannelManager_free(ptr); } public ChannelManager(LDKNetwork network, FeeEstimator fee_est, Watch chain_monitor, BroadcasterInterface tx_broadcaster, Logger logger, KeysInterface keys_manager, UserConfig config, long current_blockchain_height) { diff --git a/src/main/java/org/ldk/structs/ChannelManagerReadArgs.java b/src/main/java/org/ldk/structs/ChannelManagerReadArgs.java index de7bf4a6..a7a90e6f 100644 --- a/src/main/java/org/ldk/structs/ChannelManagerReadArgs.java +++ b/src/main/java/org/ldk/structs/ChannelManagerReadArgs.java @@ -7,7 +7,8 @@ public class ChannelManagerReadArgs extends CommonBase { ChannelManagerReadArgs(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.ChannelManagerReadArgs_free(ptr); super.finalize(); + super.finalize(); + bindings.ChannelManagerReadArgs_free(ptr); } public KeysInterface get_keys_manager(ChannelManagerReadArgs this_ptr) { diff --git a/src/main/java/org/ldk/structs/ChannelMonitor.java b/src/main/java/org/ldk/structs/ChannelMonitor.java index 7bb82499..6fe90d57 100644 --- a/src/main/java/org/ldk/structs/ChannelMonitor.java +++ b/src/main/java/org/ldk/structs/ChannelMonitor.java @@ -7,7 +7,8 @@ public class ChannelMonitor extends CommonBase { ChannelMonitor(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.ChannelMonitor_free(ptr); super.finalize(); + super.finalize(); + bindings.ChannelMonitor_free(ptr); } // Skipped ChannelMonitor_update_monitor diff --git a/src/main/java/org/ldk/structs/ChannelMonitorUpdate.java b/src/main/java/org/ldk/structs/ChannelMonitorUpdate.java index fdf417d5..7aabae2f 100644 --- a/src/main/java/org/ldk/structs/ChannelMonitorUpdate.java +++ b/src/main/java/org/ldk/structs/ChannelMonitorUpdate.java @@ -7,7 +7,8 @@ public class ChannelMonitorUpdate extends CommonBase { ChannelMonitorUpdate(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.ChannelMonitorUpdate_free(ptr); super.finalize(); + super.finalize(); + bindings.ChannelMonitorUpdate_free(ptr); } public ChannelMonitorUpdate(ChannelMonitorUpdate orig) { diff --git a/src/main/java/org/ldk/structs/ChannelPublicKeys.java b/src/main/java/org/ldk/structs/ChannelPublicKeys.java index 45fbc7d8..e62ea44f 100644 --- a/src/main/java/org/ldk/structs/ChannelPublicKeys.java +++ b/src/main/java/org/ldk/structs/ChannelPublicKeys.java @@ -7,7 +7,8 @@ public class ChannelPublicKeys extends CommonBase { ChannelPublicKeys(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.ChannelPublicKeys_free(ptr); super.finalize(); + super.finalize(); + bindings.ChannelPublicKeys_free(ptr); } public ChannelPublicKeys(ChannelPublicKeys orig) { diff --git a/src/main/java/org/ldk/structs/ChannelReestablish.java b/src/main/java/org/ldk/structs/ChannelReestablish.java index 476c9245..97f72ee3 100644 --- a/src/main/java/org/ldk/structs/ChannelReestablish.java +++ b/src/main/java/org/ldk/structs/ChannelReestablish.java @@ -7,7 +7,8 @@ public class ChannelReestablish extends CommonBase { ChannelReestablish(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.ChannelReestablish_free(ptr); super.finalize(); + super.finalize(); + bindings.ChannelReestablish_free(ptr); } public ChannelReestablish(ChannelReestablish orig) { diff --git a/src/main/java/org/ldk/structs/ChannelUpdate.java b/src/main/java/org/ldk/structs/ChannelUpdate.java index 5dc08615..d4b306b4 100644 --- a/src/main/java/org/ldk/structs/ChannelUpdate.java +++ b/src/main/java/org/ldk/structs/ChannelUpdate.java @@ -7,7 +7,8 @@ public class ChannelUpdate extends CommonBase { ChannelUpdate(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.ChannelUpdate_free(ptr); super.finalize(); + super.finalize(); + bindings.ChannelUpdate_free(ptr); } public ChannelUpdate(ChannelUpdate orig) { diff --git a/src/main/java/org/ldk/structs/ClosingSigned.java b/src/main/java/org/ldk/structs/ClosingSigned.java index 4d30d0b2..4f960828 100644 --- a/src/main/java/org/ldk/structs/ClosingSigned.java +++ b/src/main/java/org/ldk/structs/ClosingSigned.java @@ -7,7 +7,8 @@ public class ClosingSigned extends CommonBase { ClosingSigned(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.ClosingSigned_free(ptr); super.finalize(); + super.finalize(); + bindings.ClosingSigned_free(ptr); } public ClosingSigned(ClosingSigned orig) { diff --git a/src/main/java/org/ldk/structs/CommitmentSigned.java b/src/main/java/org/ldk/structs/CommitmentSigned.java index 1a8b6aa7..db4b65d0 100644 --- a/src/main/java/org/ldk/structs/CommitmentSigned.java +++ b/src/main/java/org/ldk/structs/CommitmentSigned.java @@ -7,7 +7,8 @@ public class CommitmentSigned extends CommonBase { CommitmentSigned(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.CommitmentSigned_free(ptr); super.finalize(); + super.finalize(); + bindings.CommitmentSigned_free(ptr); } public CommitmentSigned(CommitmentSigned orig) { diff --git a/src/main/java/org/ldk/structs/CommitmentUpdate.java b/src/main/java/org/ldk/structs/CommitmentUpdate.java index a5de9e9d..9f8c7a7a 100644 --- a/src/main/java/org/ldk/structs/CommitmentUpdate.java +++ b/src/main/java/org/ldk/structs/CommitmentUpdate.java @@ -7,7 +7,8 @@ public class CommitmentUpdate extends CommonBase { CommitmentUpdate(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.CommitmentUpdate_free(ptr); super.finalize(); + super.finalize(); + bindings.CommitmentUpdate_free(ptr); } public CommitmentUpdate(CommitmentUpdate orig) { diff --git a/src/main/java/org/ldk/structs/DataLossProtect.java b/src/main/java/org/ldk/structs/DataLossProtect.java index 47f90cf9..f4bf70f1 100644 --- a/src/main/java/org/ldk/structs/DataLossProtect.java +++ b/src/main/java/org/ldk/structs/DataLossProtect.java @@ -7,7 +7,8 @@ public class DataLossProtect extends CommonBase { DataLossProtect(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.DataLossProtect_free(ptr); super.finalize(); + super.finalize(); + bindings.DataLossProtect_free(ptr); } public DataLossProtect(DataLossProtect orig) { diff --git a/src/main/java/org/ldk/structs/DecodeError.java b/src/main/java/org/ldk/structs/DecodeError.java index dddda197..71ff6155 100644 --- a/src/main/java/org/ldk/structs/DecodeError.java +++ b/src/main/java/org/ldk/structs/DecodeError.java @@ -7,7 +7,8 @@ public class DecodeError extends CommonBase { DecodeError(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.DecodeError_free(ptr); super.finalize(); + super.finalize(); + bindings.DecodeError_free(ptr); } } diff --git a/src/main/java/org/ldk/structs/DirectionalChannelInfo.java b/src/main/java/org/ldk/structs/DirectionalChannelInfo.java index c708cbed..a1845552 100644 --- a/src/main/java/org/ldk/structs/DirectionalChannelInfo.java +++ b/src/main/java/org/ldk/structs/DirectionalChannelInfo.java @@ -7,7 +7,8 @@ public class DirectionalChannelInfo extends CommonBase { DirectionalChannelInfo(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.DirectionalChannelInfo_free(ptr); super.finalize(); + super.finalize(); + bindings.DirectionalChannelInfo_free(ptr); } public int get_last_update(DirectionalChannelInfo this_ptr) { diff --git a/src/main/java/org/ldk/structs/ErrorMessage.java b/src/main/java/org/ldk/structs/ErrorMessage.java index b63931d6..6d7494fa 100644 --- a/src/main/java/org/ldk/structs/ErrorMessage.java +++ b/src/main/java/org/ldk/structs/ErrorMessage.java @@ -7,7 +7,8 @@ public class ErrorMessage extends CommonBase { ErrorMessage(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.ErrorMessage_free(ptr); super.finalize(); + super.finalize(); + bindings.ErrorMessage_free(ptr); } public ErrorMessage(ErrorMessage orig) { diff --git a/src/main/java/org/ldk/structs/FundingCreated.java b/src/main/java/org/ldk/structs/FundingCreated.java index e199467c..adf4275c 100644 --- a/src/main/java/org/ldk/structs/FundingCreated.java +++ b/src/main/java/org/ldk/structs/FundingCreated.java @@ -7,7 +7,8 @@ public class FundingCreated extends CommonBase { FundingCreated(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.FundingCreated_free(ptr); super.finalize(); + super.finalize(); + bindings.FundingCreated_free(ptr); } public FundingCreated(FundingCreated orig) { diff --git a/src/main/java/org/ldk/structs/FundingLocked.java b/src/main/java/org/ldk/structs/FundingLocked.java index 1cd857e7..6b8f5b99 100644 --- a/src/main/java/org/ldk/structs/FundingLocked.java +++ b/src/main/java/org/ldk/structs/FundingLocked.java @@ -7,7 +7,8 @@ public class FundingLocked extends CommonBase { FundingLocked(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.FundingLocked_free(ptr); super.finalize(); + super.finalize(); + bindings.FundingLocked_free(ptr); } public FundingLocked(FundingLocked orig) { diff --git a/src/main/java/org/ldk/structs/FundingSigned.java b/src/main/java/org/ldk/structs/FundingSigned.java index 52819434..f0b2fa8c 100644 --- a/src/main/java/org/ldk/structs/FundingSigned.java +++ b/src/main/java/org/ldk/structs/FundingSigned.java @@ -7,7 +7,8 @@ public class FundingSigned extends CommonBase { FundingSigned(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.FundingSigned_free(ptr); super.finalize(); + super.finalize(); + bindings.FundingSigned_free(ptr); } public FundingSigned(FundingSigned orig) { diff --git a/src/main/java/org/ldk/structs/GossipTimestampFilter.java b/src/main/java/org/ldk/structs/GossipTimestampFilter.java index 5d5cc30b..862b477f 100644 --- a/src/main/java/org/ldk/structs/GossipTimestampFilter.java +++ b/src/main/java/org/ldk/structs/GossipTimestampFilter.java @@ -7,7 +7,8 @@ public class GossipTimestampFilter extends CommonBase { GossipTimestampFilter(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.GossipTimestampFilter_free(ptr); super.finalize(); + super.finalize(); + bindings.GossipTimestampFilter_free(ptr); } public GossipTimestampFilter(GossipTimestampFilter orig) { diff --git a/src/main/java/org/ldk/structs/HTLCOutputInCommitment.java b/src/main/java/org/ldk/structs/HTLCOutputInCommitment.java index d25beabe..9cf88009 100644 --- a/src/main/java/org/ldk/structs/HTLCOutputInCommitment.java +++ b/src/main/java/org/ldk/structs/HTLCOutputInCommitment.java @@ -7,7 +7,8 @@ public class HTLCOutputInCommitment extends CommonBase { HTLCOutputInCommitment(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.HTLCOutputInCommitment_free(ptr); super.finalize(); + super.finalize(); + bindings.HTLCOutputInCommitment_free(ptr); } public HTLCOutputInCommitment(HTLCOutputInCommitment orig) { diff --git a/src/main/java/org/ldk/structs/HTLCUpdate.java b/src/main/java/org/ldk/structs/HTLCUpdate.java index 01e06eb7..c8751fd3 100644 --- a/src/main/java/org/ldk/structs/HTLCUpdate.java +++ b/src/main/java/org/ldk/structs/HTLCUpdate.java @@ -7,7 +7,8 @@ public class HTLCUpdate extends CommonBase { HTLCUpdate(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.HTLCUpdate_free(ptr); super.finalize(); + super.finalize(); + bindings.HTLCUpdate_free(ptr); } public HTLCUpdate(HTLCUpdate orig) { diff --git a/src/main/java/org/ldk/structs/HolderCommitmentTransaction.java b/src/main/java/org/ldk/structs/HolderCommitmentTransaction.java index aa729ac7..9751cebc 100644 --- a/src/main/java/org/ldk/structs/HolderCommitmentTransaction.java +++ b/src/main/java/org/ldk/structs/HolderCommitmentTransaction.java @@ -7,7 +7,8 @@ public class HolderCommitmentTransaction extends CommonBase { HolderCommitmentTransaction(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.HolderCommitmentTransaction_free(ptr); super.finalize(); + super.finalize(); + bindings.HolderCommitmentTransaction_free(ptr); } public HolderCommitmentTransaction(HolderCommitmentTransaction orig) { diff --git a/src/main/java/org/ldk/structs/InMemoryChannelKeys.java b/src/main/java/org/ldk/structs/InMemoryChannelKeys.java index 1740e663..792c7527 100644 --- a/src/main/java/org/ldk/structs/InMemoryChannelKeys.java +++ b/src/main/java/org/ldk/structs/InMemoryChannelKeys.java @@ -7,7 +7,8 @@ public class InMemoryChannelKeys extends CommonBase { InMemoryChannelKeys(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.InMemoryChannelKeys_free(ptr); super.finalize(); + super.finalize(); + bindings.InMemoryChannelKeys_free(ptr); } public InMemoryChannelKeys(InMemoryChannelKeys orig) { diff --git a/src/main/java/org/ldk/structs/Init.java b/src/main/java/org/ldk/structs/Init.java index 576e95c3..491e692a 100644 --- a/src/main/java/org/ldk/structs/Init.java +++ b/src/main/java/org/ldk/structs/Init.java @@ -7,7 +7,8 @@ public class Init extends CommonBase { Init(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.Init_free(ptr); super.finalize(); + super.finalize(); + bindings.Init_free(ptr); } public Init(Init orig) { diff --git a/src/main/java/org/ldk/structs/InitFeatures.java b/src/main/java/org/ldk/structs/InitFeatures.java index 153f088f..4310438e 100644 --- a/src/main/java/org/ldk/structs/InitFeatures.java +++ b/src/main/java/org/ldk/structs/InitFeatures.java @@ -7,7 +7,8 @@ public class InitFeatures extends CommonBase { InitFeatures(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.InitFeatures_free(ptr); super.finalize(); + super.finalize(); + bindings.InitFeatures_free(ptr); } } diff --git a/src/main/java/org/ldk/structs/KeysManager.java b/src/main/java/org/ldk/structs/KeysManager.java index ca95138e..da59e435 100644 --- a/src/main/java/org/ldk/structs/KeysManager.java +++ b/src/main/java/org/ldk/structs/KeysManager.java @@ -7,7 +7,8 @@ public class KeysManager extends CommonBase { KeysManager(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.KeysManager_free(ptr); super.finalize(); + super.finalize(); + bindings.KeysManager_free(ptr); } public KeysManager(byte[] seed, LDKNetwork network, long starting_time_secs, int starting_time_nanos) { diff --git a/src/main/java/org/ldk/structs/LightningError.java b/src/main/java/org/ldk/structs/LightningError.java index 5f7391f6..4db4ea09 100644 --- a/src/main/java/org/ldk/structs/LightningError.java +++ b/src/main/java/org/ldk/structs/LightningError.java @@ -7,7 +7,8 @@ public class LightningError extends CommonBase { LightningError(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.LightningError_free(ptr); super.finalize(); + super.finalize(); + bindings.LightningError_free(ptr); } // Skipped LightningError_get_err diff --git a/src/main/java/org/ldk/structs/LockedNetworkGraph.java b/src/main/java/org/ldk/structs/LockedNetworkGraph.java index 3f1684a9..614a5d96 100644 --- a/src/main/java/org/ldk/structs/LockedNetworkGraph.java +++ b/src/main/java/org/ldk/structs/LockedNetworkGraph.java @@ -3,11 +3,10 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; -public class LockedNetworkGraph extends CommonBase { +public class LockedNetworkGraph extends CommonBase implements AutoCloseable { LockedNetworkGraph(Object _dummy, long ptr) { super(ptr); } - @Override @SuppressWarnings("deprecation") - protected void finalize() throws Throwable { - bindings.LockedNetworkGraph_free(ptr); super.finalize(); + @Override public void close() { + bindings.LockedNetworkGraph_free(ptr); } public NetworkGraph graph() { diff --git a/src/main/java/org/ldk/structs/MessageHandler.java b/src/main/java/org/ldk/structs/MessageHandler.java index b6246cd4..736bac89 100644 --- a/src/main/java/org/ldk/structs/MessageHandler.java +++ b/src/main/java/org/ldk/structs/MessageHandler.java @@ -7,7 +7,8 @@ public class MessageHandler extends CommonBase { MessageHandler(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.MessageHandler_free(ptr); super.finalize(); + super.finalize(); + bindings.MessageHandler_free(ptr); } public ChannelMessageHandler get_chan_handler(MessageHandler this_ptr) { diff --git a/src/main/java/org/ldk/structs/MonitorEvent.java b/src/main/java/org/ldk/structs/MonitorEvent.java index d4259054..35adb837 100644 --- a/src/main/java/org/ldk/structs/MonitorEvent.java +++ b/src/main/java/org/ldk/structs/MonitorEvent.java @@ -7,7 +7,8 @@ public class MonitorEvent extends CommonBase { MonitorEvent(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.MonitorEvent_free(ptr); super.finalize(); + super.finalize(); + bindings.MonitorEvent_free(ptr); } } diff --git a/src/main/java/org/ldk/structs/MonitorUpdateError.java b/src/main/java/org/ldk/structs/MonitorUpdateError.java index f56c45a5..bd0eefc8 100644 --- a/src/main/java/org/ldk/structs/MonitorUpdateError.java +++ b/src/main/java/org/ldk/structs/MonitorUpdateError.java @@ -7,7 +7,8 @@ public class MonitorUpdateError extends CommonBase { MonitorUpdateError(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.MonitorUpdateError_free(ptr); super.finalize(); + super.finalize(); + bindings.MonitorUpdateError_free(ptr); } } diff --git a/src/main/java/org/ldk/structs/NetGraphMsgHandler.java b/src/main/java/org/ldk/structs/NetGraphMsgHandler.java index b475109b..bb976f65 100644 --- a/src/main/java/org/ldk/structs/NetGraphMsgHandler.java +++ b/src/main/java/org/ldk/structs/NetGraphMsgHandler.java @@ -7,7 +7,8 @@ public class NetGraphMsgHandler extends CommonBase { NetGraphMsgHandler(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.NetGraphMsgHandler_free(ptr); super.finalize(); + super.finalize(); + bindings.NetGraphMsgHandler_free(ptr); } public NetGraphMsgHandler(Access chain_access, Logger logger) { diff --git a/src/main/java/org/ldk/structs/NetworkGraph.java b/src/main/java/org/ldk/structs/NetworkGraph.java index e2f64ee0..f18a9645 100644 --- a/src/main/java/org/ldk/structs/NetworkGraph.java +++ b/src/main/java/org/ldk/structs/NetworkGraph.java @@ -7,7 +7,8 @@ public class NetworkGraph extends CommonBase { NetworkGraph(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.NetworkGraph_free(ptr); super.finalize(); + super.finalize(); + bindings.NetworkGraph_free(ptr); } // Skipped NetworkGraph_write diff --git a/src/main/java/org/ldk/structs/NodeAnnouncement.java b/src/main/java/org/ldk/structs/NodeAnnouncement.java index b114815f..019017c3 100644 --- a/src/main/java/org/ldk/structs/NodeAnnouncement.java +++ b/src/main/java/org/ldk/structs/NodeAnnouncement.java @@ -7,7 +7,8 @@ public class NodeAnnouncement extends CommonBase { NodeAnnouncement(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.NodeAnnouncement_free(ptr); super.finalize(); + super.finalize(); + bindings.NodeAnnouncement_free(ptr); } public NodeAnnouncement(NodeAnnouncement orig) { diff --git a/src/main/java/org/ldk/structs/NodeAnnouncementInfo.java b/src/main/java/org/ldk/structs/NodeAnnouncementInfo.java index fe13f99f..e9a35ffb 100644 --- a/src/main/java/org/ldk/structs/NodeAnnouncementInfo.java +++ b/src/main/java/org/ldk/structs/NodeAnnouncementInfo.java @@ -7,7 +7,8 @@ public class NodeAnnouncementInfo extends CommonBase { NodeAnnouncementInfo(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.NodeAnnouncementInfo_free(ptr); super.finalize(); + super.finalize(); + bindings.NodeAnnouncementInfo_free(ptr); } public NodeFeatures get_features(NodeAnnouncementInfo this_ptr) { diff --git a/src/main/java/org/ldk/structs/NodeFeatures.java b/src/main/java/org/ldk/structs/NodeFeatures.java index fe418ad3..a9016680 100644 --- a/src/main/java/org/ldk/structs/NodeFeatures.java +++ b/src/main/java/org/ldk/structs/NodeFeatures.java @@ -7,7 +7,8 @@ public class NodeFeatures extends CommonBase { NodeFeatures(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.NodeFeatures_free(ptr); super.finalize(); + super.finalize(); + bindings.NodeFeatures_free(ptr); } } diff --git a/src/main/java/org/ldk/structs/NodeInfo.java b/src/main/java/org/ldk/structs/NodeInfo.java index acfc3c4c..4812f2f3 100644 --- a/src/main/java/org/ldk/structs/NodeInfo.java +++ b/src/main/java/org/ldk/structs/NodeInfo.java @@ -7,7 +7,8 @@ public class NodeInfo extends CommonBase { NodeInfo(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.NodeInfo_free(ptr); super.finalize(); + super.finalize(); + bindings.NodeInfo_free(ptr); } // Skipped NodeInfo_set_channels diff --git a/src/main/java/org/ldk/structs/OpenChannel.java b/src/main/java/org/ldk/structs/OpenChannel.java index 87e7d179..e497933d 100644 --- a/src/main/java/org/ldk/structs/OpenChannel.java +++ b/src/main/java/org/ldk/structs/OpenChannel.java @@ -7,7 +7,8 @@ public class OpenChannel extends CommonBase { OpenChannel(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.OpenChannel_free(ptr); super.finalize(); + super.finalize(); + bindings.OpenChannel_free(ptr); } public OpenChannel(OpenChannel orig) { diff --git a/src/main/java/org/ldk/structs/OutPoint.java b/src/main/java/org/ldk/structs/OutPoint.java index 18229e76..12fffe16 100644 --- a/src/main/java/org/ldk/structs/OutPoint.java +++ b/src/main/java/org/ldk/structs/OutPoint.java @@ -7,7 +7,8 @@ public class OutPoint extends CommonBase { OutPoint(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.OutPoint_free(ptr); super.finalize(); + super.finalize(); + bindings.OutPoint_free(ptr); } public OutPoint(OutPoint orig) { diff --git a/src/main/java/org/ldk/structs/PaymentSendFailure.java b/src/main/java/org/ldk/structs/PaymentSendFailure.java index 7eb6a56a..1df65ed0 100644 --- a/src/main/java/org/ldk/structs/PaymentSendFailure.java +++ b/src/main/java/org/ldk/structs/PaymentSendFailure.java @@ -7,7 +7,8 @@ public class PaymentSendFailure extends CommonBase { PaymentSendFailure(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.PaymentSendFailure_free(ptr); super.finalize(); + super.finalize(); + bindings.PaymentSendFailure_free(ptr); } } diff --git a/src/main/java/org/ldk/structs/PeerHandleError.java b/src/main/java/org/ldk/structs/PeerHandleError.java index 24c350e8..6586e91c 100644 --- a/src/main/java/org/ldk/structs/PeerHandleError.java +++ b/src/main/java/org/ldk/structs/PeerHandleError.java @@ -7,7 +7,8 @@ public class PeerHandleError extends CommonBase { PeerHandleError(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.PeerHandleError_free(ptr); super.finalize(); + super.finalize(); + bindings.PeerHandleError_free(ptr); } public boolean get_no_connection_possible(PeerHandleError this_ptr) { diff --git a/src/main/java/org/ldk/structs/PeerManager.java b/src/main/java/org/ldk/structs/PeerManager.java index 54b4e723..319b979e 100644 --- a/src/main/java/org/ldk/structs/PeerManager.java +++ b/src/main/java/org/ldk/structs/PeerManager.java @@ -7,7 +7,8 @@ public class PeerManager extends CommonBase { PeerManager(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.PeerManager_free(ptr); super.finalize(); + super.finalize(); + bindings.PeerManager_free(ptr); } public PeerManager(ChannelMessageHandler message_handler_chan_handler_arg, RoutingMessageHandler message_handler_route_handler_arg, byte[] our_node_secret, byte[] ephemeral_random_data, Logger logger) { diff --git a/src/main/java/org/ldk/structs/Ping.java b/src/main/java/org/ldk/structs/Ping.java index e0e1b3d5..a6cc369b 100644 --- a/src/main/java/org/ldk/structs/Ping.java +++ b/src/main/java/org/ldk/structs/Ping.java @@ -7,7 +7,8 @@ public class Ping extends CommonBase { Ping(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.Ping_free(ptr); super.finalize(); + super.finalize(); + bindings.Ping_free(ptr); } public Ping(Ping orig) { diff --git a/src/main/java/org/ldk/structs/Pong.java b/src/main/java/org/ldk/structs/Pong.java index 0ddec80c..a674d05a 100644 --- a/src/main/java/org/ldk/structs/Pong.java +++ b/src/main/java/org/ldk/structs/Pong.java @@ -7,7 +7,8 @@ public class Pong extends CommonBase { Pong(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.Pong_free(ptr); super.finalize(); + super.finalize(); + bindings.Pong_free(ptr); } public Pong(Pong orig) { diff --git a/src/main/java/org/ldk/structs/PreCalculatedTxCreationKeys.java b/src/main/java/org/ldk/structs/PreCalculatedTxCreationKeys.java index 2a88b869..26222393 100644 --- a/src/main/java/org/ldk/structs/PreCalculatedTxCreationKeys.java +++ b/src/main/java/org/ldk/structs/PreCalculatedTxCreationKeys.java @@ -7,7 +7,8 @@ public class PreCalculatedTxCreationKeys extends CommonBase { PreCalculatedTxCreationKeys(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.PreCalculatedTxCreationKeys_free(ptr); super.finalize(); + super.finalize(); + bindings.PreCalculatedTxCreationKeys_free(ptr); } public PreCalculatedTxCreationKeys(TxCreationKeys keys) { diff --git a/src/main/java/org/ldk/structs/QueryChannelRange.java b/src/main/java/org/ldk/structs/QueryChannelRange.java index c1a8b3f2..9d15fee3 100644 --- a/src/main/java/org/ldk/structs/QueryChannelRange.java +++ b/src/main/java/org/ldk/structs/QueryChannelRange.java @@ -7,7 +7,8 @@ public class QueryChannelRange extends CommonBase { QueryChannelRange(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.QueryChannelRange_free(ptr); super.finalize(); + super.finalize(); + bindings.QueryChannelRange_free(ptr); } public QueryChannelRange(QueryChannelRange orig) { diff --git a/src/main/java/org/ldk/structs/QueryShortChannelIds.java b/src/main/java/org/ldk/structs/QueryShortChannelIds.java index 316e4f94..e43f686d 100644 --- a/src/main/java/org/ldk/structs/QueryShortChannelIds.java +++ b/src/main/java/org/ldk/structs/QueryShortChannelIds.java @@ -7,7 +7,8 @@ public class QueryShortChannelIds extends CommonBase { QueryShortChannelIds(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.QueryShortChannelIds_free(ptr); super.finalize(); + super.finalize(); + bindings.QueryShortChannelIds_free(ptr); } public QueryShortChannelIds(QueryShortChannelIds orig) { diff --git a/src/main/java/org/ldk/structs/ReplyChannelRange.java b/src/main/java/org/ldk/structs/ReplyChannelRange.java index 43ccf5d2..7d33ba4b 100644 --- a/src/main/java/org/ldk/structs/ReplyChannelRange.java +++ b/src/main/java/org/ldk/structs/ReplyChannelRange.java @@ -7,7 +7,8 @@ public class ReplyChannelRange extends CommonBase { ReplyChannelRange(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.ReplyChannelRange_free(ptr); super.finalize(); + super.finalize(); + bindings.ReplyChannelRange_free(ptr); } public ReplyChannelRange(ReplyChannelRange orig) { diff --git a/src/main/java/org/ldk/structs/ReplyShortChannelIdsEnd.java b/src/main/java/org/ldk/structs/ReplyShortChannelIdsEnd.java index c04cd58a..6ea3e720 100644 --- a/src/main/java/org/ldk/structs/ReplyShortChannelIdsEnd.java +++ b/src/main/java/org/ldk/structs/ReplyShortChannelIdsEnd.java @@ -7,7 +7,8 @@ public class ReplyShortChannelIdsEnd extends CommonBase { ReplyShortChannelIdsEnd(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.ReplyShortChannelIdsEnd_free(ptr); super.finalize(); + super.finalize(); + bindings.ReplyShortChannelIdsEnd_free(ptr); } public ReplyShortChannelIdsEnd(ReplyShortChannelIdsEnd orig) { diff --git a/src/main/java/org/ldk/structs/RevokeAndACK.java b/src/main/java/org/ldk/structs/RevokeAndACK.java index d887797c..1c7a4a03 100644 --- a/src/main/java/org/ldk/structs/RevokeAndACK.java +++ b/src/main/java/org/ldk/structs/RevokeAndACK.java @@ -7,7 +7,8 @@ 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) { diff --git a/src/main/java/org/ldk/structs/Route.java b/src/main/java/org/ldk/structs/Route.java index dc1f9645..aa4dd123 100644 --- a/src/main/java/org/ldk/structs/Route.java +++ b/src/main/java/org/ldk/structs/Route.java @@ -7,7 +7,8 @@ public class Route extends CommonBase { Route(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.Route_free(ptr); super.finalize(); + super.finalize(); + bindings.Route_free(ptr); } public Route(Route orig) { diff --git a/src/main/java/org/ldk/structs/RouteHint.java b/src/main/java/org/ldk/structs/RouteHint.java index 71fdc7fe..f7897200 100644 --- a/src/main/java/org/ldk/structs/RouteHint.java +++ b/src/main/java/org/ldk/structs/RouteHint.java @@ -7,7 +7,8 @@ public class RouteHint extends CommonBase { RouteHint(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.RouteHint_free(ptr); super.finalize(); + super.finalize(); + bindings.RouteHint_free(ptr); } public RouteHint(RouteHint orig) { diff --git a/src/main/java/org/ldk/structs/RouteHop.java b/src/main/java/org/ldk/structs/RouteHop.java index 814ebe5a..a094d172 100644 --- a/src/main/java/org/ldk/structs/RouteHop.java +++ b/src/main/java/org/ldk/structs/RouteHop.java @@ -7,7 +7,8 @@ public class RouteHop extends CommonBase { RouteHop(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.RouteHop_free(ptr); super.finalize(); + super.finalize(); + bindings.RouteHop_free(ptr); } public RouteHop(RouteHop orig) { diff --git a/src/main/java/org/ldk/structs/RoutingFees.java b/src/main/java/org/ldk/structs/RoutingFees.java index 59f65ce5..80183bb9 100644 --- a/src/main/java/org/ldk/structs/RoutingFees.java +++ b/src/main/java/org/ldk/structs/RoutingFees.java @@ -7,7 +7,8 @@ public class RoutingFees extends CommonBase { RoutingFees(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.RoutingFees_free(ptr); super.finalize(); + super.finalize(); + bindings.RoutingFees_free(ptr); } public RoutingFees(RoutingFees orig) { diff --git a/src/main/java/org/ldk/structs/Shutdown.java b/src/main/java/org/ldk/structs/Shutdown.java index 8c690a9d..d1b08971 100644 --- a/src/main/java/org/ldk/structs/Shutdown.java +++ b/src/main/java/org/ldk/structs/Shutdown.java @@ -7,7 +7,8 @@ public class Shutdown extends CommonBase { Shutdown(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.Shutdown_free(ptr); super.finalize(); + super.finalize(); + bindings.Shutdown_free(ptr); } public Shutdown(Shutdown orig) { diff --git a/src/main/java/org/ldk/structs/TxCreationKeys.java b/src/main/java/org/ldk/structs/TxCreationKeys.java index 39849ae5..0e2cc4ae 100644 --- a/src/main/java/org/ldk/structs/TxCreationKeys.java +++ b/src/main/java/org/ldk/structs/TxCreationKeys.java @@ -7,7 +7,8 @@ public class TxCreationKeys extends CommonBase { TxCreationKeys(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.TxCreationKeys_free(ptr); super.finalize(); + super.finalize(); + bindings.TxCreationKeys_free(ptr); } public TxCreationKeys(TxCreationKeys orig) { diff --git a/src/main/java/org/ldk/structs/UnsignedChannelAnnouncement.java b/src/main/java/org/ldk/structs/UnsignedChannelAnnouncement.java index 7af52146..e11c520c 100644 --- a/src/main/java/org/ldk/structs/UnsignedChannelAnnouncement.java +++ b/src/main/java/org/ldk/structs/UnsignedChannelAnnouncement.java @@ -7,7 +7,8 @@ public class UnsignedChannelAnnouncement extends CommonBase { UnsignedChannelAnnouncement(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.UnsignedChannelAnnouncement_free(ptr); super.finalize(); + super.finalize(); + bindings.UnsignedChannelAnnouncement_free(ptr); } public UnsignedChannelAnnouncement(UnsignedChannelAnnouncement orig) { diff --git a/src/main/java/org/ldk/structs/UnsignedChannelUpdate.java b/src/main/java/org/ldk/structs/UnsignedChannelUpdate.java index f56cca90..b3520d33 100644 --- a/src/main/java/org/ldk/structs/UnsignedChannelUpdate.java +++ b/src/main/java/org/ldk/structs/UnsignedChannelUpdate.java @@ -7,7 +7,8 @@ public class UnsignedChannelUpdate extends CommonBase { UnsignedChannelUpdate(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.UnsignedChannelUpdate_free(ptr); super.finalize(); + super.finalize(); + bindings.UnsignedChannelUpdate_free(ptr); } public UnsignedChannelUpdate(UnsignedChannelUpdate orig) { diff --git a/src/main/java/org/ldk/structs/UnsignedNodeAnnouncement.java b/src/main/java/org/ldk/structs/UnsignedNodeAnnouncement.java index 3a20d820..adee1f66 100644 --- a/src/main/java/org/ldk/structs/UnsignedNodeAnnouncement.java +++ b/src/main/java/org/ldk/structs/UnsignedNodeAnnouncement.java @@ -7,7 +7,8 @@ public class UnsignedNodeAnnouncement extends CommonBase { UnsignedNodeAnnouncement(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.UnsignedNodeAnnouncement_free(ptr); super.finalize(); + super.finalize(); + bindings.UnsignedNodeAnnouncement_free(ptr); } public UnsignedNodeAnnouncement(UnsignedNodeAnnouncement orig) { diff --git a/src/main/java/org/ldk/structs/UpdateAddHTLC.java b/src/main/java/org/ldk/structs/UpdateAddHTLC.java index adca17e6..86bb2b41 100644 --- a/src/main/java/org/ldk/structs/UpdateAddHTLC.java +++ b/src/main/java/org/ldk/structs/UpdateAddHTLC.java @@ -7,7 +7,8 @@ public class UpdateAddHTLC extends CommonBase { UpdateAddHTLC(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.UpdateAddHTLC_free(ptr); super.finalize(); + super.finalize(); + bindings.UpdateAddHTLC_free(ptr); } public UpdateAddHTLC(UpdateAddHTLC orig) { diff --git a/src/main/java/org/ldk/structs/UpdateFailHTLC.java b/src/main/java/org/ldk/structs/UpdateFailHTLC.java index b1cb0329..50147508 100644 --- a/src/main/java/org/ldk/structs/UpdateFailHTLC.java +++ b/src/main/java/org/ldk/structs/UpdateFailHTLC.java @@ -7,7 +7,8 @@ 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) { diff --git a/src/main/java/org/ldk/structs/UpdateFailMalformedHTLC.java b/src/main/java/org/ldk/structs/UpdateFailMalformedHTLC.java index 8f414a98..66e394dd 100644 --- a/src/main/java/org/ldk/structs/UpdateFailMalformedHTLC.java +++ b/src/main/java/org/ldk/structs/UpdateFailMalformedHTLC.java @@ -7,7 +7,8 @@ public class UpdateFailMalformedHTLC extends CommonBase { UpdateFailMalformedHTLC(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.UpdateFailMalformedHTLC_free(ptr); super.finalize(); + super.finalize(); + bindings.UpdateFailMalformedHTLC_free(ptr); } public UpdateFailMalformedHTLC(UpdateFailMalformedHTLC orig) { diff --git a/src/main/java/org/ldk/structs/UpdateFee.java b/src/main/java/org/ldk/structs/UpdateFee.java index 9fd24408..9756771b 100644 --- a/src/main/java/org/ldk/structs/UpdateFee.java +++ b/src/main/java/org/ldk/structs/UpdateFee.java @@ -7,7 +7,8 @@ public class UpdateFee extends CommonBase { UpdateFee(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.UpdateFee_free(ptr); super.finalize(); + super.finalize(); + bindings.UpdateFee_free(ptr); } public UpdateFee(UpdateFee orig) { diff --git a/src/main/java/org/ldk/structs/UpdateFulfillHTLC.java b/src/main/java/org/ldk/structs/UpdateFulfillHTLC.java index 96f58430..5bb0940a 100644 --- a/src/main/java/org/ldk/structs/UpdateFulfillHTLC.java +++ b/src/main/java/org/ldk/structs/UpdateFulfillHTLC.java @@ -7,7 +7,8 @@ public class UpdateFulfillHTLC extends CommonBase { UpdateFulfillHTLC(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.UpdateFulfillHTLC_free(ptr); super.finalize(); + super.finalize(); + bindings.UpdateFulfillHTLC_free(ptr); } public UpdateFulfillHTLC(UpdateFulfillHTLC orig) { diff --git a/src/main/java/org/ldk/structs/UserConfig.java b/src/main/java/org/ldk/structs/UserConfig.java index a22d021b..5ebd15c9 100644 --- a/src/main/java/org/ldk/structs/UserConfig.java +++ b/src/main/java/org/ldk/structs/UserConfig.java @@ -7,7 +7,8 @@ public class UserConfig extends CommonBase { UserConfig(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.UserConfig_free(ptr); super.finalize(); + super.finalize(); + bindings.UserConfig_free(ptr); } public UserConfig(UserConfig orig) { diff --git a/src/test/java/org/ldk/HumanObjectPeerTest.java b/src/test/java/org/ldk/HumanObjectPeerTest.java index 935eadb9..8103b23c 100644 --- a/src/test/java/org/ldk/HumanObjectPeerTest.java +++ b/src/test/java/org/ldk/HumanObjectPeerTest.java @@ -127,11 +127,12 @@ public class HumanObjectPeerTest { } long get_route(byte[] dest_node, long our_chans) { - LockedNetworkGraph netgraph = this.router.read_locked_graph(); - //r = new WeakReference(netgraph); - NetworkGraph graph = netgraph.graph(); - return bindings.get_route(this.node_id, graph._test_only_get_ptr(), dest_node, our_chans, - bindings.LDKCVecTempl_RouteHint_new(new long[0]), 1000, 42, this.logger); + try (LockedNetworkGraph netgraph = this.router.read_locked_graph()) { + //r = new WeakReference(netgraph); + NetworkGraph graph = netgraph.graph(); + return bindings.get_route(this.node_id, graph._test_only_get_ptr(), dest_node, our_chans, + bindings.LDKCVecTempl_RouteHint_new(new long[0]), 1000, 42, this.logger); + } } } @@ -273,8 +274,6 @@ public class HumanObjectPeerTest { for (int i = 0; i < 32; i++) payment_preimage[i] = (byte) (i ^ 0x0f); byte[] payment_hash = Sha256Hash.hash(payment_preimage); long route = peer1.get_route(peer2.node_id, peer1_chans); - System.gc(); // Force the lock to release that we took in get_route - we need something better here! - System.runFinalization(); bindings.CVec_ChannelDetailsZ_free(peer1_chans); assert bindings.LDKCResult_RouteLightningErrorZ_result_ok(route); long payment_res = bindings.ChannelManager_send_payment(peer1.chan_manager._test_only_get_ptr(), bindings.LDKCResult_RouteLightningErrorZ_get_inner(route), payment_hash, new byte[32]);