Class GlobalRef

    • Field Detail

      • factory

        public static ReferenceBackendFactory factory
        This is a hook for JyNI to insert a native-objects-aware implementation of ReferenceBackend.
    • Constructor Detail

      • GlobalRef

        public GlobalRef​(PyObject object)
    • Method Detail

      • find

        public AbstractReference find​(java.lang.Class<?> cls)
        Search for a reusable reference. To be reused, it must be of the same class and it must not have a callback.
        Specified by:
        find in interface ReferenceBackend
      • hasDelayedCallbacks

        public static boolean hasDelayedCallbacks()
      • newInstance

        public static ReferenceBackend newInstance​(PyObject object)
        Create a new tracked ReferenceBackend. If no ReferenceBackendFactory is registered, it actually returns a GlobalRef.
        Parameters:
        object - a PyObject to reference
        Returns:
        a new tracked ReferenceBackend
      • restore

        public void restore​(PyObject formerReferent)
        Restores this weak reference to its former referent. This actually means that a fresh GlobalRef is created and inserted into all adjacent AbstractReferences. The current GlobalRef is disbanded. If the given PyObject is not the former referent of this weak reference, an IllegalArgumentException is thrown.
        Specified by:
        restore in interface ReferenceBackend
        Throws:
        java.lang.IllegalArgumentException - if formerReferent is not the actual former referent.
      • getCount

        public static int getCount​(PyObject object)
        Return the number of references to the specified PyObject.
        Parameters:
        object - a PyObject
        Returns:
        an int reference count
      • getRefs

        public static PyList getRefs​(PyObject object)
        Return a list of references to the specified PyObject.
        Parameters:
        object - a PyObject
        Returns:
        a PyList of references. May be empty.
      • equals

        public boolean equals​(java.lang.Object o)
        Allow GlobalRefs to be used as hashtable-keys.
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Allows GlobalRef to be used as hashtable-keys.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        a hashCode int-value