import org.ldk.enums.*;
import org.ldk.util.*;
import java.util.Arrays;
+import java.lang.ref.Reference;
import javax.annotation.Nullable;
/**
protected void finalize() throws Throwable {
if (ptr != 0) { bindings.CustomMessageReader_free(ptr); } super.finalize();
}
-
+ /**
+ * Destroys the object, freeing associated resources. After this call, any access
+ * to this object may result in a SEGFAULT or worse.
+ *
+ * You should generally NEVER call this method. You should let the garbage collector
+ * do this for you when it finalizes objects. However, it may be useful for types
+ * which represent locks and should be closed immediately to avoid holding locks
+ * until the GC runs.
+ */
+ public void destroy() {
+ if (ptr != 0) { bindings.CustomMessageReader_free(ptr); }
+ ptr = 0;
+ }
public static interface CustomMessageReaderInterface {
/**
* Decodes a custom message to `CustomMessageType`. If the given message type is known to the
impl_holder.held = new CustomMessageReader(new bindings.LDKCustomMessageReader() {
@Override public long read(short message_type, byte[] buffer) {
Result_COption_TypeZDecodeErrorZ ret = arg.read(message_type, buffer);
- long result = ret != null ? ret.ptr : 0;
+ Reference.reachabilityFence(arg);
+ long result = ret == null ? 0 : ret.clone_ptr();
return result;
}
});
*/
public Result_COption_TypeZDecodeErrorZ read(short message_type, byte[] buffer) {
long ret = bindings.CustomMessageReader_read(this.ptr, message_type, buffer);
- if (ret >= 0 && ret < 1024) { return null; }
+ Reference.reachabilityFence(this);
+ Reference.reachabilityFence(message_type);
+ Reference.reachabilityFence(buffer);
+ if (ret >= 0 && ret <= 4096) { return null; }
Result_COption_TypeZDecodeErrorZ ret_hu_conv = Result_COption_TypeZDecodeErrorZ.constr_from_ptr(ret);
return ret_hu_conv;
}