Class CoroutineWriter


  • public final class CoroutineWriter
    extends java.lang.Object
    Writes out (serializes) the current state of a CoroutineRunner object.
    • Field Detail

      • updatersMap

        private final java.util.Map updatersMap
      • interceptersMap

        private final java.util.Map interceptersMap
    • Constructor Detail

      • CoroutineWriter

        public CoroutineWriter()
        Construct a CoroutineWriter object. Equivalent to calling new CoroutineWriter(new DefaultCoroutineSerializer(), new FrameUpdatePoint[0], new FrameInterceptPoint[0]).
      • CoroutineWriter

        public CoroutineWriter​(SerializedState.FrameUpdatePoint[] frameUpdatePoints)
        Constructs a CoroutineWriter. Equivalent to calling new CoroutineWriter(new DefaultCoroutineSerializer(), frameUpdatePoints, new FrameInterceptPoint[0]).
        Parameters:
        frameUpdatePoints - frame update points
        Throws:
        java.lang.IllegalArgumentException - if frameUpdatePoints contains more than one entry for the same identifier (className/oldMethodId/newMethodId/continuationPoint)
        java.lang.NullPointerException - if any argument is null
      • CoroutineWriter

        public CoroutineWriter​(SerializedState.FrameInterceptPoint[] frameInterceptPoints)
        Constructs a CoroutineWriter. Equivalent to calling new CoroutineWriter(new DefaultCoroutineSerializer(), new FrameUpdatePoint[0], frameInterceptPoints).
        Parameters:
        frameInterceptPoints - frame intercept points
        Throws:
        java.lang.IllegalArgumentException - if frameInterceptPoints contains more than one entry for the same identifier (className/methodId/continuationPoint)
        java.lang.NullPointerException - if any argument is null
      • CoroutineWriter

        public CoroutineWriter​(SerializedState.FrameUpdatePoint[] frameUpdatePoints,
                               SerializedState.FrameInterceptPoint[] frameInterceptPoints)
        Constructs a CoroutineWriter. Equivalent to calling new CoroutineWriter(new DefaultCoroutineSerializer(), frameUpdatePoints, frameInterceptPoints).
        Parameters:
        frameUpdatePoints - frame update points
        frameInterceptPoints - frame intercept points
        Throws:
        java.lang.IllegalArgumentException - if frameUpdatePoints contains more than one entry for the same identifier (className/oldMethodId/newMethodId/continuationPoint), or if frameInterceptPoints contains more than one entry for the same identifier (className/methodId/continuationPoint)
        java.lang.NullPointerException - if any argument is null
      • CoroutineWriter

        public CoroutineWriter​(CoroutineWriter.CoroutineSerializer serializer,
                               SerializedState.FrameUpdatePoint[] frameUpdatePoints,
                               SerializedState.FrameInterceptPoint[] frameInterceptPoints)
        Constructs a CoroutineWriter object.
        Parameters:
        serializer - serializer to write out the coroutine state
        frameUpdatePoints - frame update points
        frameInterceptPoints - frame intercept points
        Throws:
        java.lang.NullPointerException - if any argument is null or contains null
        java.lang.IllegalArgumentException - if frameUpdatePoints contains more than one entry for the same identifier (className/oldMethodId/newMethodId/continuationPoint), or if frameInterceptPoints contains more than one entry for the same identifier (className/methodId/continuationPoint)
    • Method Detail

      • write

        public byte[] write​(CoroutineRunner runner)
        Serializes a CoroutineRunner object as a byte array.
        Parameters:
        runner - coroutine runner to serialize
        Returns:
        runner serialized to byte array
        Throws:
        java.lang.NullPointerException - if any argument is null
        java.lang.IllegalArgumentException - if failed to serialize
      • deconstruct

        public SerializedState deconstruct​(CoroutineRunner runner)
        Deconstructs a CoroutineRunner object to a serializable state.
        Parameters:
        runner - coroutine runner to deconstruct
        Returns:
        deconstructed representation of CoroutineRunner
        Throws:
        java.lang.NullPointerException - if any argument is null
        java.lang.IllegalArgumentException - if failed to deconstruct
      • clearContinuationReferences

        private int[] clearContinuationReferences​(java.lang.Object[] objects,
                                                  Continuation cn)