Package com.sun.jna
Class CallbackReference
- java.lang.Object
-
- java.lang.ref.Reference<T>
-
- java.lang.ref.WeakReference<Callback>
-
- com.sun.jna.CallbackReference
-
public class CallbackReference extends WeakReference<Callback>
Provides a reference to an association between a native callback closure and a JavaCallbackclosure.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classCallbackReference.AttachOptions
-
Field Summary
Fields Modifier and Type Field Description (package private) static Map<Object,Object>allocations(package private) static Map<Callback,CallbackReference>callbackMap(package private) intcallingConvention(package private) Pointercbstruct(package private) static Map<Callback,CallbackReference>directCallbackMap(package private) Methodmethod(package private) static Map<Pointer,Reference<Callback>>pointerCallbackMap(package private) CallbackProxyproxy(package private) Pointertrampoline
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddispose()Free native resources associated with this callback.(package private) static voiddisposeAll()Dispose of all memory allocated for callbacks.protected voidfinalize()Free native resources associated with this callback when GC'd.(package private) static Class<?>findCallbackClass(Class<?> type)static CallbackgetCallback(Class<?> type, Pointer p)Return a Callback associated with the given function pointer.static PointergetFunctionPointer(Callback cb)Return aPointerto the native function address for the given callback.PointergetTrampoline()Obtain a pointer to the native glue code for this callback.(package private) static CallbackThreadInitializersetCallbackThreadInitializer(Callback cb, CallbackThreadInitializer initializer)-
Methods inherited from class java.lang.ref.Reference
clear, clone, enqueue, get, isEnqueued, reachabilityFence
-
-
-
-
Field Detail
-
callbackMap
static final Map<Callback,CallbackReference> callbackMap
-
directCallbackMap
static final Map<Callback,CallbackReference> directCallbackMap
-
cbstruct
Pointer cbstruct
-
trampoline
Pointer trampoline
-
proxy
CallbackProxy proxy
-
method
Method method
-
callingConvention
int callingConvention
-
-
Method Detail
-
setCallbackThreadInitializer
static CallbackThreadInitializer setCallbackThreadInitializer(Callback cb, CallbackThreadInitializer initializer)
- Parameters:
cb- TheCallbackinstanceinitializer- TheCallbackThreadInitializer- ifnullthen the associated initializer instance is removed- Returns:
- The previous initializer instance (may be
null)
-
getCallback
public static Callback getCallback(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:
IllegalStateException- if the given pointer has already been mapped to a callback of a different 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.
-
dispose
protected void dispose()
Free native resources associated with this callback.
-
disposeAll
static void disposeAll()
Dispose of all memory allocated for callbacks.
-
-