Fix serialVersionUID for EmptyMap and EmptySet

Otherwise removal of redundant special stubs
leads to InvalidClassException during deserialization
This commit is contained in:
Denis Zharkov
2016-10-06 11:09:05 +03:00
parent dfb9b323ff
commit 1ad9f1c985
2 changed files with 5 additions and 1 deletions
@@ -7,6 +7,8 @@ import java.io.Serializable
import java.util.*
private object EmptyMap : Map<Any?, Nothing>, Serializable {
private const val serialVersionUID: Long = 8246714829545688274
override fun equals(other: Any?): Boolean = other is Map<*,*> && other.isEmpty()
override fun hashCode(): Int = 0
override fun toString(): String = "{}"
@@ -8,6 +8,8 @@ import java.util.*
internal object EmptySet : Set<Nothing>, Serializable {
private const val serialVersionUID: Long = 3406603774387020532
override fun equals(other: Any?): Boolean = other is Set<*> && other.isEmpty()
override fun hashCode(): Int = 0
override fun toString(): String = "[]"
@@ -80,4 +82,4 @@ internal fun <T> Set<T>.optimizeReadOnlySet() = when (size) {
0 -> emptySet()
1 -> setOf(iterator().next())
else -> this
}
}