Class CoroutineReader


  • public final class CoroutineReader
    extends java.lang.Object
    Reads in (deserializes) the state of a CoroutineRunner object.
    • Field Detail

      • updatersMap

        private final java.util.Map updatersMap
      • interceptersMap

        private final java.util.Map interceptersMap
    • Constructor Detail

      • CoroutineReader

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

        public CoroutineReader​(SerializedState.FrameUpdatePoint[] frameUpdatePoints)
        Constructs a CoroutineReader. Equivalent to calling new CoroutineReader(new DefaultCoroutineDeserializer(), 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
      • CoroutineReader

        public CoroutineReader​(SerializedState.FrameInterceptPoint[] frameInterceptPoints)
        Constructs a CoroutineReader. Equivalent to calling new CoroutineReader(new DefaultCoroutineDeserializer(), 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
      • CoroutineReader

        public CoroutineReader​(SerializedState.FrameUpdatePoint[] frameUpdatePoints,
                               SerializedState.FrameInterceptPoint[] frameInterceptPoints)
        Constructs a CoroutineReader. Equivalent to calling new CoroutineReader(new DefaultCoroutineDeserializer(), 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
      • CoroutineReader

        public CoroutineReader​(CoroutineReader.CoroutineDeserializer deserializer,
                               SerializedState.FrameUpdatePoint[] frameUpdatePoints,
                               SerializedState.FrameInterceptPoint[] frameInterceptPoints)
        Constructs a CoroutineReader object.
        Parameters:
        deserializer - deserializer 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

      • read

        public CoroutineRunner read​(byte[] data)
        Deserializes a CoroutineRunner object from a byte array.

        If you're handling your own deserialization and you simply want to reconstruct the deserialized object to the CoroutineRunner, use reconstruct(com.offbynull.coroutines.user.SerializedState).

        Parameters:
        data - byte array to deserialize
        Returns:
        data deserialized to a CoroutineRunner object
        Throws:
        java.lang.NullPointerException - if any argument is null
        java.lang.IllegalArgumentException - if failed to deserialize or deserialized to a state for an unrecognized method (e.g. a method that's state is being deserialized for was changed but no SerializedState.FrameUpdatePoint was provided to this class's constructor to handle the changes)
      • reconstruct

        public CoroutineRunner reconstruct​(SerializedState state)
        Reconstructs a CoroutineRunner object from a serializable state.
        Parameters:
        state - serialized state to reconstruct
        Returns:
        reconstructed CoroutineRunner
        Throws:
        java.lang.NullPointerException - if any argument is null
        java.lang.IllegalArgumentException - if state contains a reference / was updated to contain a reference to an unrecognized method (e.g. a method that's state is being reconstructed for was changed but no SerializedState.FrameUpdatePoint was provided to this class's constructor to handle the changes)
      • placeContinuationReferences

        private void placeContinuationReferences​(int[] continuationIndexes,
                                                 java.lang.Object[] objects,
                                                 Continuation cn)