Class NativeObject
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
AsyncExecutor
,AsyncOperator
,Operator
NativeObject has the close()
method, which frees its associated
native object.
This function should be called manually, or even better, called implicitly using a
try-with-resources
statement, when you are finished with the object. It is no longer called automatically
during the regular Java GC process via Object.finalize()
.
Explanatory note
When or if the Garbage Collector calls Object.finalize()
depends on the JVM implementation and system conditions, which the programmer
cannot control. In addition, the GC cannot see through the native reference
long member variable (which is the pointer value to the native object),
and cannot know what other resources depend on it.
Finalization is deprecated and subject to removal in a future release. The use of finalization can lead to problems with security, performance, and reliability. See JEP 421 for discussion and alternatives.
-
Field Summary
Modifier and TypeFieldDescriptionprotected final long
An immutable reference to the value of the underneath pointer pointing to some underlying native OpenDAL object. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
protected abstract void
disposeInternal
(long handle) Deletes underlying native object pointer.boolean
Check if the object has been disposed.
-
Field Details
-
nativeHandle
protected final long nativeHandleAn immutable reference to the value of the underneath pointer pointing to some underlying native OpenDAL object.
-
-
Constructor Details
-
NativeObject
protected NativeObject(long nativeHandle)
-
-
Method Details
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-
isDisposed
public boolean isDisposed()Check if the object has been disposed. Useful for defensive programming.- Returns:
- if the object has been disposed.
-
disposeInternal
protected abstract void disposeInternal(long handle) Deletes underlying native object pointer.- Parameters:
handle
- to the native object pointer
-