Serializability of coroutine classes
See original GitHub issueCurrently, if you attempt to serialize coroutine state via standard Java Serialization the tree of reference leads you to the objects defined in kotlinx.coroutines
like StandaloneCoroutine
(which serves as a completion for launched coroutines) and its contexts (like CommonPool
) which are not currently serializable. They should be made properly serializable.
See also https://github.com/Kotlin/kotlin-coroutines/issues/28
Issue Analytics
- State:
- Created 6 years ago
- Reactions:9
- Comments:56 (19 by maintainers)
Top Results From Across the Web
Serializable class with coroutines? - Stack Overflow
I have a class, which I want to make serializable (to see some public variables in the inspector), but I also need to...
Read more >Serializable class with coroutines? - Unity Answers
Serializable class with coroutines? I have a class, which I want to make serializable (to see some public variables in the inspector), but...
Read more >Make SafeContinuation and context impl classes serializable
The following classes from kotlin.coroutines.experimental package shall be made serializable so that coroutines can be readily serialized with Java ...
Read more >Serializable Coroutines for the HotSpot™ Java Virtual Machine
4.2.8 The CoroutineSupport Class . ... It only needs to take care of non-serializable classes, as shown in Section 5.2. In a more...
Read more >Is it possible to serialize a Kotlin coroutine and resume it later ...
Theoretically yes. However, there's no guarantee that the captured stack is fully serializable. AFAIK it's a talking topic in the coroutines ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think it would be very useful to implement long running business processes. The tools that are available for this are usually proprietary using some incomplete home brew expression language and flow control. And almost all of them use proprietary storage and run platform. As a result you can’t use proper version control, proper debugging, proper module reuse, proper cloud deployment etc. So I being able to use coroutines to implement this would be incredibly exciting.
@pdvrieze I’m thinking along the lines that if we go with
kotlinx.serialzation
support in the future, then we’ll be explicitly annotating suspending functions and lambda as@Serializable
and the compiler will guarantee that they only capture and work with serializable classes.