@Throws(IOException::class, ClassNotFoundException::class) private fun readObject(`in`: ObjectInputStream) { val inName = `in`.readObject() as String val inDescription = `in`.readObject() as String val inValue = `in`.readObject() val inClass = `in`.readObject() as Class<*> val inUserModifiable = `in`.readBoolean() Assert.assertTrue(inName != null) Assert.assertTrue(inDescription != null) Assert.assertTrue(inValue != null) Assert.assertTrue(inClass != null) this.deserialized = true this.name = inName setInternalState(inDescription, inValue, inClass, inUserModifiable) }
Override readObject which is used in serialization . Customize serialization of this exception to avoid escape of InternalRole which is not Serializable .