public interface DebugMode
Interface that may be implemented by TransientHandlers to debug the serialization process.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Serializable
    A placeholder to indicate that a not serializable object should be nullified during serialization process.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    Silently checks if serialization object tracking is available on this JVM.
    static boolean
    isTrackingAvailable(org.slf4j.Logger logger)
    Checks if serialization object tracking is available on this JVM.
    default void
    Hook invoked when deserialization process is about to start.
    default void
    onDeserialize(Class<?> type, Track track, Object object)
    Hook notified when deserialization of an object of give type is started.
    default Object
    onDeserialized(Object object, Track track)
    Tracks an object right after deserialization Implementors can provide a replacement for current processing object.
    Hook invoked when a not Serializable object is found during serialization process.
    default void
    Hook invoked when serialization process is about to start.
    default Object
    onSerialize(Object object, Track track)
    Tracks an object being serialized.
  • Field Details

    • NULLIFY

      static final Serializable NULLIFY
      A placeholder to indicate that a not serializable object should be nullified during serialization process.
  • Method Details

    • onSerializationStart

      default void onSerializationStart()
      Hook invoked when serialization process is about to start.
    • onNotSerializableFound

      default Optional<Serializable> onNotSerializableFound(Object object)
      Hook invoked when a not Serializable object is found during serialization process. Implementors can provide a serializable replacement object to prevent NotSerializableException or an empty Optional to continue processing with the input object. If an empty optional is returned, the serialization process will continue and fail fast on input Object with a NotSerializableException. To proceed the serialization process ignoring the current object, implementor can return the special value NULLIFY. This will inform the serialization process to replace the input object with null value, avoiding NotSerializableException. In this modality, object fields will be ignored and not serialized. Default strategy is to continue processing with the current object and let the process fail with NotSerializableException.
      Parameters:
      object - the not serializable object instance, never null.
      Returns:
      a serializable replacement for the input object or an empty Optional, never null.
      See Also:
    • onSerialize

      default Object onSerialize(Object object, Track track)
      Tracks an object being serialized. NOTE: implementation is not supposed not alter the input object, nor to throw any kind on exception.
      Parameters:
      object - object that is going to be serialized.
    • onDeserializationStart

      default void onDeserializationStart()
      Hook invoked when deserialization process is about to start.
    • onDeserialize

      default void onDeserialize(Class<?> type, Track track, Object object)
      Hook notified when deserialization of an object of give type is started.
      Parameters:
      type - Java type of the object to deserialize.
      track - The tracking information for object to deserialize.
    • onDeserialized

      default Object onDeserialized(Object object, Track track)
      Tracks an object right after deserialization Implementors can provide a replacement for current processing object. By default, the input object is returned.
      Parameters:
      object - object that is going to be serialized.
    • isTrackingAvailable

      static boolean isTrackingAvailable(org.slf4j.Logger logger)
      Checks if serialization object tracking is available on this JVM. For it to be enabled two pre-conditions must match:
      • sun.io.serialization.extendedDebugInfo system property must be set to true
      • reflection on java.io package must be allowed through the `--add-opens` flag (e.g. '--add-opens java.base/java.io=ALL-UNNAMED')
      Parameters:
      logger - logger to print hints when preconditions are not met. May be null if log is not required.
      Returns:
      true if extend debug info is activated, otherwise false.
    • isTrackingAvailable

      static boolean isTrackingAvailable()
      Silently checks if serialization object tracking is available on this JVM.
      See Also: