Class Callback

  • All Implemented Interfaces:
    java.lang.AutoCloseable, NativeResource, Pointer
    Direct Known Subclasses:
    EnumerationMutationHandler, WindowProc

    public abstract class Callback
    extends java.lang.Object
    implements Pointer, NativeResource
    Base class for dynamically created native functions that call into Java code.

    Callback instances use native resources and must be explicitly freed when no longer used by calling the free() method.

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String __stdcall​(java.lang.String signature)  
      long address()
      Returns the raw pointer address as a long value.
      boolean equals​(java.lang.Object o)  
      void free()
      Frees any native resources held by this object.
      static void free​(long functionPointer)
      Frees any resources held by the specified function pointer.
      static <T extends CallbackI>
      T
      get​(long functionPointer)
      Converts the specified function pointer to the CallbackI instance associated with it.
      static <T extends CallbackI>
      T
      getSafe​(long functionPointer)
      Like get(long), but returns null if functionPointer is NULL.
      int hashCode()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Method Detail

      • address

        public long address()
        Description copied from interface: Pointer
        Returns the raw pointer address as a long value.
        Specified by:
        address in interface Pointer
        Returns:
        the pointer address
      • free

        public void free()
        Description copied from interface: NativeResource
        Frees any native resources held by this object.
        Specified by:
        free in interface NativeResource
      • __stdcall

        public static java.lang.String __stdcall​(java.lang.String signature)
      • get

        public static <T extends CallbackI> T get​(long functionPointer)
        Converts the specified function pointer to the CallbackI instance associated with it.
        Type Parameters:
        T - the CallbackI instance type
        Parameters:
        functionPointer - a function pointer
        Returns:
        the CallbackI instance
      • getSafe

        @Nullable
        public static <T extends CallbackI> T getSafe​(long functionPointer)
        Like get(long), but returns null if functionPointer is NULL.
      • free

        public static void free​(long functionPointer)
        Frees any resources held by the specified function pointer.
        Parameters:
        functionPointer - the function pointer
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object