Package org.signal.libsignal.internal
Class NativeHandleGuard
- java.lang.Object
-
- org.signal.libsignal.internal.NativeHandleGuard
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class NativeHandleGuard extends java.lang.Object implements java.lang.AutoCloseableProvides access to a Rust object handle while keeping the Java wrapper alive. Intended for use with try-with-resources syntax. NativeHandleGuard prevents the Java wrapper from being finalized, which would destroy the Rust object, while the handle is in use. To use it, the Java wrapper type should conform to theNativeHandleGuard.Ownerinterface. Note that it is not necessary to use NativeHandleGuard in the implementation offinalizeitself. The point of NativeHandleGuard is to delay finalization while the Rust object is being used; once finalization has begun, there can be no other uses of the Rust object from Java.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceNativeHandleGuard.Owner
-
Constructor Summary
Constructors Constructor Description NativeHandleGuard(NativeHandleGuard.Owner owner)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()longnativeHandle()Returns the native handle owned by the Java object, or 0 if the owner isnull.
-
-
-
Constructor Detail
-
NativeHandleGuard
public NativeHandleGuard(NativeHandleGuard.Owner owner)
-
-