Make generated classes support `Serializable` under Kotlin/JVM
Opened this issue · 0 comments
Classes generated by pbandk should implement Serializable
under Kotlin/JVM so that they can be included inside of other Serializable
classes. See #140 for some motivating use cases. This would provide feature parity with protobuf-java
, which does generate classes that implement Serializable
.
This is hard to implement directly in the generated code since the generated code can only reference classes available to the common
sourceset of a Kotlin Multiplatform project, but the java.io.Serializable
interface is only available under Kotlin/JVM. However, #31 is going to change the classes generated by pbandk to extend from a pbandk.GeneratedMessage
class. Once that is in place, we can use expect/actual
to create different implementations of GeneratedMessage
for each Kotlin platform. Then the Kotlin/JVM implementation of GeneratedMessage
can implement java.io.Serializable
and custom readObject()
/writeObject()
methods as needed (or maybe we'll need to use writeReplace()
and readResolve()
?).