FinalizeTrigger (Jython API documentation)
Date: 2020-03-21

org.python.core.finalization

## Class FinalizeTrigger

- java.lang.Object
- - org.python.core.finalization.FinalizeTrigger

-     public class FinalizeTrigger
      extends java.lang.Object

  To use finalizers on `PyObject`s, read the documentation of `FinalizablePyObject`.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static FinalizeTriggerFactory` | `factory` This factory hook is reserved for use by JyNI.
    `static byte` | `FINALIZED_FLAG` Indicates that this trigger was already finalized.
    `byte` | `flags`
    `static byte` | `NOT_FINALIZABLE_FLAG` Indicates that the underlying PyObject was never intended to be finalized.
    `static byte` | `NOTIFY_GC_FLAG` This flag tells the finalize trigger to call `gc.notifyFinalize(PyObject)` after it called the finalizer.
    `static byte` | `ONLY_BUILTIN_FLAG` Indicates that only `FinalizableBuiltin` shall be called.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `appendFinalizeTriggerForBuiltin(PyObject obj)`
    `void` | `clear()`
    `static void` | `ensureFinalizer(PyObject resurrect)` Recreates the `FinalizeTrigger` of the given object.
    `static boolean` | `hasActiveTrigger(PyObject obj)`
    `boolean` | `isActive()`
    `static boolean` | `isFinalizable(PyObject obj)`
    `boolean` | `isFinalized()`
    `static FinalizeTrigger` | `makeTrigger(PyObject toFinalize)`
    `void` | `performFinalization()`
    `static void` | `runFinalizer(PyObject toFinalize)`
    `static void` | `runFinalizer(PyObject toFinalize, boolean runBuiltinOnly)`
    `void` | `trigger(PyObject toFinalize)`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### NOTIFY_GC_FLAG

          public static final byte NOTIFY_GC_FLAG

      This flag tells the finalize trigger to call `gc.notifyFinalize(PyObject)` after it called the finalizer.
      See Also:
        Constant Field Values

    - #### NOT_FINALIZABLE_FLAG

          public static final byte NOT_FINALIZABLE_FLAG

      Indicates that the underlying PyObject was never intended to be finalized. It is actually not finalizable and the trigger only exists to notify `gc` that the underlying object was finalized. This is needed for some advanced gc-functionality.
      See Also:
        Constant Field Values

    - #### ONLY_BUILTIN_FLAG

          public static final byte ONLY_BUILTIN_FLAG

      Indicates that only `FinalizableBuiltin` shall be called.
      See Also:
        Constant Field Values

    - #### FINALIZED_FLAG

          public static final byte FINALIZED_FLAG

      Indicates that this trigger was already finalized.
      See Also:
        Constant Field Values

    - #### factory

          public static FinalizeTriggerFactory factory

      This factory hook is reserved for use by JyNI. It allows to replace the default `FinalizeTrigger`. JyNI needs it to support garbage collection.

    - #### flags

          public byte flags

  - ### Method Detail

    - #### makeTrigger

          public static FinalizeTrigger makeTrigger(PyObject toFinalize)

    - #### hasActiveTrigger

          public static boolean hasActiveTrigger(PyObject obj)

    - #### isFinalizable

          public static boolean isFinalizable(PyObject obj)

    - #### ensureFinalizer

          public static void ensureFinalizer(PyObject resurrect)

      Recreates the `FinalizeTrigger` of the given object. This makes sure that once the resurrected object is gc'ed again, its `__del__`-method will be called again.

    - #### runFinalizer

          public static void runFinalizer(PyObject toFinalize)

    - #### runFinalizer

          public static void runFinalizer(PyObject toFinalize,
                                          boolean runBuiltinOnly)

    - #### appendFinalizeTriggerForBuiltin

          public static void appendFinalizeTriggerForBuiltin(PyObject obj)

    - #### clear

          public void clear()

    - #### trigger

          public void trigger(PyObject toFinalize)

    - #### isActive

          public boolean isActive()

    - #### performFinalization

          public void performFinalization()

    - #### isFinalized

          public boolean isFinalized()

Jython homepage