public abstract class NativeEnclosure
extends java.lang.Object
implements java.lang.AutoCloseable
try (NEC obj = new NEC(...)) { // ... do something with obj ... }Extending classes implement acquireNativeResources() and releaseNativeResources(). Before this instance is passed to the JNI layer, open() should be called, allocating all necessary resources. After making all necessary JNI calls, close() should be called to free resources. Ideally, open() and close() should be called close to the JNI calls, wrapped by the developer to limit accidental memory leaks.
Modifier and Type | Field and Description |
---|---|
NativeProxy |
mPointer
Enclosed NativeProxy reference.
|
long |
mPointerSize
Size of enclosed mPointer.
|
Constructor and Description |
---|
NativeEnclosure() |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
acquireNativeResources()
Allocate native resources, setting mPointer and mPointerSize as
appropriate.
|
void |
close()
Deinitialize and free mPointer.
|
protected void |
finalize()
Deprecated.
|
void |
open()
Allocate and initialize mPointer with its enclosed value.
|
protected abstract void |
releaseNativeResources()
Called to deallocate native resources; note that mPointer.close()
is called afterwards.
|
public NativeProxy mPointer
public long mPointerSize
public final void open() throws java.lang.Exception
java.lang.Exception
@Deprecated protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public final void close() throws java.lang.Exception
close
in interface java.lang.AutoCloseable
java.lang.Exception
protected abstract void acquireNativeResources() throws java.lang.Exception
java.lang.Exception
protected abstract void releaseNativeResources() throws java.lang.Exception
java.lang.Exception