question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Implement java.io.Serializable on the JVM

See original GitHub issue

Hello, Please make the Android actual types implement also java.io.Serializable (not Kotlin @Serializable as described in #37). This will allow us to make the complex types, which depends on kotlinx.datetime.* types either Serializable or Parcelable in Android app.

For instance, java.time.Instant IS Serializable, however the actual Android class kotlinx.datetime.Instant is NOT.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
smallufocommented, Sep 20, 2021

Not related to android. I want to use kotlinx-datetime in wicket. But all wicket models mandate Serializable interface, otherwise NotSerializableException will be thrown.

1reaction
dkhalanskyjbcommented, Nov 22, 2021

What do you think about writing Serializable Adapters for our classes in place? We provide compatible toString and parse for everything.

An overly cautious example that can be slightly simplified if you know what you’re doing:

public data class LocalDateModel(@Transient var value: LocalDate): java.io.Serializable {
    private fun writeObject(oStream: ObjectOutputStream) {
        oStream.defaultWriteObject()
        oStream.writeObject(value.toString())
    }
    private fun readObject(iStream: ObjectInputStream) {
        iStream.defaultReadObject()
        value = LocalDate.parse(iStream.readObject() as String)
    }
    private fun readObjectNoData() {
        throw InvalidObjectException("Stream data required")
    }
}

(be careful to check out serialVersionUid if you plan to change this class)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Serialization in Java - DigitalOcean
io. Serializable interface. Serializable in java is a marker interface and has no fields or methods to implement.
Read more >
Serializable (Java SE 11 & JDK 11 ) - Oracle Help Center
Serializability of a class is enabled by the class implementing the java.io.Serializable interface. Warning: Deserialization of untrusted data is inherently ...
Read more >
Introduction to Java Serialization | Baeldung
The serialization process is instance-independent; for example, we can serialize objects on one platform and deserialize them on another.
Read more >
Serialization and Deserialization in Java with Example
To make a Java object serializable we implement the java.io.Serializable interface. The ObjectOutputStream class contains writeObject() ...
Read more >
Why Do We Need Serialization in Java? - CodeJava.net
io.Serializable interface. Serializable is a marker interface (contains no methods) that tell the Java Virtual Machine (JVM) that the objects of ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found