diff --git a/src/dorkbox/network/serialization/Serialization.kt b/src/dorkbox/network/serialization/Serialization.kt index f2bd74c4..c60ac992 100644 --- a/src/dorkbox/network/serialization/Serialization.kt +++ b/src/dorkbox/network/serialization/Serialization.kt @@ -140,7 +140,7 @@ open class Serialization(private val references: Boolean = true, private val fac * * This must happen before the creation of the client/server */ - fun register(clazz: Class): Serialization { + open fun register(clazz: Class): Serialization { require(!initialized.value) { "Serialization 'register(class)' cannot happen after client/server initialization!" } // The reason it must be an implementation, is because the reflection serializer DOES NOT WORK with field types, but rather @@ -165,7 +165,7 @@ open class Serialization(private val references: Boolean = true, private val fac * @param id Must be >= 0. Smaller IDs are serialized more efficiently. IDs 0-8 are used by default for primitive types and String, but * these IDs can be repurposed. */ - fun register(clazz: Class, id: Int): Serialization { + open fun register(clazz: Class, id: Int): Serialization { require(!initialized.value) { "Serialization 'register(Class, int)' cannot happen after client/server initialization!" } // The reason it must be an implementation, is because the reflection serializer DOES NOT WORK with field types, but rather @@ -188,7 +188,7 @@ open class Serialization(private val references: Boolean = true, private val fac * method. The order must be the same at deserialization as it was for serialization. */ @Synchronized - fun register(clazz: Class, serializer: Serializer): Serialization { + open fun register(clazz: Class, serializer: Serializer): Serialization { require(!initialized.value) { "Serialization 'register(Class, Serializer)' cannot happen after client/server initialization!" } // The reason it must be an implementation, is because the reflection serializer DOES NOT WORK with field types, but rather @@ -213,7 +213,7 @@ open class Serialization(private val references: Boolean = true, private val fac * these IDs can be repurposed. */ @Synchronized - fun register(clazz: Class, serializer: Serializer, id: Int): Serialization { + open fun register(clazz: Class, serializer: Serializer, id: Int): Serialization { require(!initialized.value) { "Serialization 'register(Class, Serializer, int)' cannot happen after client/server initialization!" } // The reason it must be an implementation, is because the reflection serializer DOES NOT WORK with field types, but rather @@ -239,7 +239,7 @@ open class Serialization(private val references: Boolean = true, private val fac * @throws IllegalArgumentException if the iface/impl have previously been overridden */ @Synchronized - fun registerRmi(ifaceClass: Class, implClass: Class? = null): Serialization { + open fun registerRmi(ifaceClass: Class, implClass: Class? = null): Serialization { require(!initialized.value) { "Serialization 'registerRmi(Class, Class)' cannot happen after client/server initialization!" } require(ifaceClass.isInterface) { "Cannot register an implementation for RMI access. It must be an interface." } @@ -395,7 +395,7 @@ open class Serialization(private val references: Boolean = true, private val fac // this will set up the class registration information return if (type == Server::class.java) { if (!initialized.compareAndSet(expect = false, update = true)) { - logger.error("Unable to initialize serialization more than once!") + require(false) { "Unable to initialize serialization more than once!" } return false }