Package com.sun.jna
Class CallbackReference
- java.lang.Object
-
- java.lang.ref.Reference<T>
-
- java.lang.ref.WeakReference<Callback>
-
- com.sun.jna.CallbackReference
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
CallbackReference.AttachOptions
-
Field Summary
Fields Modifier and Type Field Description (package private) static java.util.Map<java.lang.Object,java.lang.Object>
allocations
(package private) static java.util.Map<Callback,CallbackReference>
callbackMap
(package private) int
callingConvention
(package private) Pointer
cbstruct
(package private) static java.util.Map<Callback,CallbackReference>
directCallbackMap
(package private) java.lang.reflect.Method
method
(package private) static java.util.Map<Pointer,java.lang.ref.Reference<Callback>[]>
pointerCallbackMap
(package private) CallbackProxy
proxy
(package private) Pointer
trampoline
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
dispose()
Free native resources associated with this callback.(package private) static void
disposeAll()
Dispose of all memory allocated for callbacks.protected void
finalize()
Free native resources associated with this callback when GC'd.(package private) static java.lang.Class<?>
findCallbackClass(java.lang.Class<?> type)
static Callback
getCallback(java.lang.Class<?> type, Pointer p)
Return a Callback associated with the given function pointer.static Pointer
getFunctionPointer(Callback cb)
Return aPointer
to the native function address for the given callback.Pointer
getTrampoline()
Obtain a pointer to the native glue code for this callback.(package private) static CallbackThreadInitializer
setCallbackThreadInitializer(Callback cb, CallbackThreadInitializer initializer)
-
-
-
Field Detail
-
callbackMap
static final java.util.Map<Callback,CallbackReference> callbackMap
-
directCallbackMap
static final java.util.Map<Callback,CallbackReference> directCallbackMap
-
pointerCallbackMap
static final java.util.Map<Pointer,java.lang.ref.Reference<Callback>[]> pointerCallbackMap
-
allocations
static final java.util.Map<java.lang.Object,java.lang.Object> allocations
-
cbstruct
Pointer cbstruct
-
trampoline
Pointer trampoline
-
proxy
CallbackProxy proxy
-
method
java.lang.reflect.Method method
-
callingConvention
int callingConvention
-
-
Method Detail
-
setCallbackThreadInitializer
static CallbackThreadInitializer setCallbackThreadInitializer(Callback cb, CallbackThreadInitializer initializer)
- Parameters:
cb
- TheCallback
instanceinitializer
- TheCallbackThreadInitializer
- ifnull
then the associated initializer instance is removed- Returns:
- The previous initializer instance (may be
null
)
-
getCallback
public static Callback getCallback(java.lang.Class<?> type, Pointer p)
Return a Callback associated with the given function pointer. If the pointer refers to a Java callback trampoline, return the original Java Callback. Otherwise, return a proxy to the native function pointer.- Throws:
java.lang.IllegalStateException
- if the given pointer has already been mapped to a callback of a different type.
-
findCallbackClass
static java.lang.Class<?> findCallbackClass(java.lang.Class<?> type)
-
getTrampoline
public Pointer getTrampoline()
Obtain a pointer to the native glue code for this callback.
-
finalize
protected void finalize()
Free native resources associated with this callback when GC'd.- Overrides:
finalize
in classjava.lang.Object
-
dispose
protected void dispose()
Free native resources associated with this callback.
-
disposeAll
static void disposeAll()
Dispose of all memory allocated for callbacks.
-
-