Skip to content

Commit 0195b29

Browse files
committed
Do not implement Instant: java.io.Serializable
1 parent 803ccc4 commit 0195b29

File tree

3 files changed

+2
-20
lines changed

3 files changed

+2
-20
lines changed

core/jvm/src/Instant.kt

+1-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import java.time.Clock as jtClock
2222
@Serializable(with = InstantIso8601Serializer::class)
2323
public actual class Instant internal constructor(
2424
internal val value: jtInstant
25-
) : Comparable<Instant>, java.io.Serializable {
25+
) : Comparable<Instant> {
2626

2727
public actual val epochSeconds: Long
2828
get() = value.epochSecond
@@ -100,8 +100,6 @@ public actual class Instant internal constructor(
100100
internal actual val MIN: Instant = Instant(jtInstant.MIN)
101101
internal actual val MAX: Instant = Instant(jtInstant.MAX)
102102
}
103-
104-
private fun writeReplace(): Any = Ser(Ser.INSTANT_TAG, this)
105103
}
106104

107105
private fun Instant.atZone(zone: TimeZone): java.time.ZonedDateTime = try {

core/jvm/src/internal/Ser.kt

+1-9
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ internal class Ser(private var typeTag: Int, private var value: Any?) : External
1616
out.writeByte(typeTag)
1717
val value = this.value
1818
when (typeTag) {
19-
INSTANT_TAG -> {
20-
value as Instant
21-
out.writeLong(value.epochSeconds)
22-
out.writeInt(value.nanosecondsOfSecond)
23-
}
2419
DATE_TAG -> {
2520
value as LocalDate
2621
out.writeLong(value.value.toEpochDay())
@@ -45,8 +40,6 @@ internal class Ser(private var typeTag: Int, private var value: Any?) : External
4540
override fun readExternal(`in`: ObjectInput) {
4641
typeTag = `in`.readByte().toInt()
4742
value = when (typeTag) {
48-
INSTANT_TAG ->
49-
Instant.fromEpochSeconds(`in`.readLong(), `in`.readInt())
5043
DATE_TAG ->
5144
LocalDate(java.time.LocalDate.ofEpochDay(`in`.readLong()))
5245
TIME_TAG ->
@@ -66,10 +59,9 @@ internal class Ser(private var typeTag: Int, private var value: Any?) : External
6659

6760
companion object {
6861
private const val serialVersionUID: Long = 0L
69-
const val INSTANT_TAG = 1
7062
const val DATE_TAG = 2
7163
const val TIME_TAG = 3
7264
const val DATE_TIME_TAG = 4
7365
const val UTC_OFFSET_TAG = 10
7466
}
75-
}
67+
}

core/jvm/test/JvmSerializationTest.kt

-8
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,6 @@ import kotlin.test.*
1010

1111
class JvmSerializationTest {
1212

13-
@Test
14-
fun serializeInstant() {
15-
roundTripSerialization(Instant.fromEpochSeconds(1234567890, 123456789))
16-
roundTripSerialization(Instant.MIN)
17-
roundTripSerialization(Instant.MAX)
18-
expectedDeserialization(Instant.parse("+150000-04-30T12:30:25.555998Z"), "0d010000043fa44d82612123db30")
19-
}
20-
2113
@Test
2214
fun serializeLocalTime() {
2315
roundTripSerialization(LocalTime(12, 34, 56, 789))

0 commit comments

Comments
 (0)