Parcelable: Array serializer should correctly handle wide primitive types – long, double (KT-20002)
This commit is contained in:
committed by
Yan Zhulanow
parent
32fc340d62
commit
c9ec1a2511
+39
@@ -0,0 +1,39 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
@file:JvmName("TestKt")
|
||||
package test
|
||||
|
||||
import kotlinx.android.parcel.*
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import java.util.Arrays
|
||||
|
||||
@Parcelize
|
||||
data class Test(val a: LongArray, val b: List<Long>) : Parcelable {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other?.javaClass != javaClass) return false
|
||||
|
||||
other as Test
|
||||
|
||||
if (!Arrays.equals(a, other.a)) return false
|
||||
if (b != other.b) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode() = Arrays.hashCode(a)
|
||||
}
|
||||
|
||||
fun box() = parcelTest { parcel ->
|
||||
val first = Test(longArrayOf(1, 2, 3, 4, 5), listOf(1, 2, 3, 4))
|
||||
|
||||
first.writeToParcel(parcel, 0)
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
|
||||
val first2 = readFromParcel<Test>(parcel)
|
||||
|
||||
assert(first == first2)
|
||||
}
|
||||
Vendored
+3
-3
@@ -36,9 +36,9 @@ public final class Test : java/lang/Object {
|
||||
INVOKEINTERFACE (java/util/Iterator, hasNext, ()Z)
|
||||
IFEQ (L2)
|
||||
DUP
|
||||
INVOKEINTERFACE (java/util/Iterator, next, ()Ljava/lang/Object;)
|
||||
ALOAD (1)
|
||||
SWAP
|
||||
INVOKEINTERFACE (java/util/Iterator, next, ()Ljava/lang/Object;)
|
||||
CHECKCAST
|
||||
DUP_X1
|
||||
INVOKEINTERFACE (java/util/Collection, size, ()I)
|
||||
@@ -49,9 +49,9 @@ public final class Test : java/lang/Object {
|
||||
INVOKEINTERFACE (java/util/Iterator, hasNext, ()Z)
|
||||
IFEQ (L4)
|
||||
DUP
|
||||
INVOKEINTERFACE (java/util/Iterator, next, ()Ljava/lang/Object;)
|
||||
ALOAD (1)
|
||||
SWAP
|
||||
INVOKEINTERFACE (java/util/Iterator, next, ()Ljava/lang/Object;)
|
||||
CHECKCAST
|
||||
DUP_X1
|
||||
INVOKEINTERFACE (java/util/Collection, size, ()I)
|
||||
@@ -62,9 +62,9 @@ public final class Test : java/lang/Object {
|
||||
INVOKEINTERFACE (java/util/Iterator, hasNext, ()Z)
|
||||
IFEQ (L6)
|
||||
DUP
|
||||
INVOKEINTERFACE (java/util/Iterator, next, ()Ljava/lang/Object;)
|
||||
ALOAD (1)
|
||||
SWAP
|
||||
INVOKEINTERFACE (java/util/Iterator, next, ()Ljava/lang/Object;)
|
||||
CHECKCAST
|
||||
INVOKEVIRTUAL (android/os/Parcel, writeString, (Ljava/lang/String;)V)
|
||||
GOTO (L5)
|
||||
|
||||
Vendored
+1
-1
@@ -36,9 +36,9 @@ public final class Test : java/lang/Object {
|
||||
INVOKEINTERFACE (java/util/Iterator, hasNext, ()Z)
|
||||
IFEQ (L2)
|
||||
DUP
|
||||
INVOKEINTERFACE (java/util/Iterator, next, ()Ljava/lang/Object;)
|
||||
ALOAD (1)
|
||||
SWAP
|
||||
INVOKEINTERFACE (java/util/Iterator, next, ()Ljava/lang/Object;)
|
||||
CHECKCAST
|
||||
INVOKEVIRTUAL (android/os/Parcel, writeString, (Ljava/lang/String;)V)
|
||||
GOTO (L1)
|
||||
|
||||
Reference in New Issue
Block a user