Class PointerScope

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class PointerScope
    extends java.lang.Object
    implements java.lang.AutoCloseable
    Pointer objects attach themselves automatically on Pointer.init(long, long, long, long) to the first PointerScope found in scopeStack that they can to based on the classes found in forClasses. The user can then call deallocate(), or rely on close() to release in a timely fashion all attached Pointer objects, instead of relying on the garbage collector.
    • Field Detail

      • logger

        private static final Logger logger
      • pointerStack

        java.util.Deque<Pointer> pointerStack
        The stack keeping references to attached Pointer objects.
      • forClasses

        java.lang.Class<? extends Pointer>[] forClasses
        When not empty, indicates the classes of objects that are allowed to be attached.
      • extend

        boolean extend
        When set to true, the next call to close() does not release but resets this variable.
    • Constructor Detail

      • PointerScope

        public PointerScope()
        Creates a new scope accepting all pointer types and pushes itself on the scopeStack.
      • PointerScope

        public PointerScope​(java.lang.Class<? extends Pointer>... forClasses)
        Initializes forClasses, and pushes itself on the scopeStack.