28import java.util.concurrent.atomic.AtomicBoolean;
46 private long nativeInstance;
47 private final AtomicBoolean isNativeValid =
new AtomicBoolean(
false);
48 private final Object nativeLock =
new Object();
56 this.nativeInstance = nativeInstance;
57 isNativeValid.set(
true);
58 initNativeJavaObject(nativeInstance);
62 this.nativeInstance = 0;
63 isNativeValid.set(
false);
66 synchronized (nativeLock) {
67 if( isNativeValid.compareAndSet(
false,
true) ) {
68 this.nativeInstance = nativeInstance;
69 initNativeJavaObject(nativeInstance);
71 System.err.println(
"DBTNativeDownlink.init2: Already valid, dropping nativeInstance 0x"+Long.toHexString(nativeInstance));
96 synchronized (nativeLock) {
97 if( !isNativeValid.compareAndSet(
true,
false) ) {
99 System.err.println(
"JAVA: delete: !valid -> bail: "+getClass().getSimpleName());
104 System.err.println(
"JAVA: delete.0: "+getClass().getSimpleName()+
": valid, handle 0x"+Long.toHexString(nativeInstance));
106 final long _nativeInstance = nativeInstance;
108 deleteNativeJavaObject(_nativeInstance);
111 System.err.println(
"JAVA: delete.X: "+getClass().getSimpleName()+
": handle 0x"+Long.toHexString(nativeInstance));
120 private final void notifyDeleted() {
121 synchronized (nativeLock) {
122 final boolean _isValid = isNativeValid.get();
123 final long _nativeInstance = nativeInstance;
124 isNativeValid.set(
false);
127 System.err.println(
"JAVA: delete.notifyDeleted: "+getClass().getSimpleName()+
", was: valid "+_isValid+
", handle 0x"+Long.toHexString(_nativeInstance)+
": "+toString());
145 private native
void initNativeJavaObject(
final long nativeInstance);
146 private native
void deleteNativeJavaObject(
final long nativeInstance);
static final boolean DEBUG
Java counterpart to C++ jau::JavaUplink.
final void delete()
Deletes the nativeInstance in the following order.
final boolean isNativeValid()
Returns true if native instance is valid, otherwise false.
abstract void deleteImpl(long nativeInstance)
Deletes the native instance.
final void initDownlink(final long nativeInstance)
DBTNativeDownlink(final long nativeInstance)