Created
June 7, 2018 09:18
-
-
Save nesterchung/6905c09f142a7a493e95f2a2bd3b20ce to your computer and use it in GitHub Desktop.
Serializable crash demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A : Serializable { | |
var b: B? = null | |
} | |
// without serializable | |
class B { | |
} | |
fun main(args: Array<String>) { | |
val a = A() | |
val oos = ObjectOutputStream(ByteArrayOutputStream()) | |
oos.writeObject(a) | |
oos.close() //ok | |
val a2 = A() | |
a2.b = B() // put an non serializable object | |
val oos2 = ObjectOutputStream(ByteArrayOutputStream()) | |
oos2.writeObject(a2) | |
oos2.close() //gg | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment