Parcelable: Add Parcelable functionality to Android Extensions plugin

This commit is contained in:
Yan Zhulanow
2017-06-16 16:52:29 +03:00
parent edd8a0a64e
commit c23bca6afe
47 changed files with 2979 additions and 3 deletions
@@ -0,0 +1,14 @@
package android.os
class Parcel
interface Parcelable {
fun describeContents(): Int
fun writeToParcel(parcel: Parcel, flags: Int)
interface Creator<T> {
fun createFromParcel(parcel: Parcel): T
fun newArray(size: Int): Array<T>
}
}
@@ -0,0 +1,38 @@
// WITH_RUNTIME
@file:JvmName("TestKt")
package test
import kotlinx.android.parcel.*
import android.os.Parcel
import android.os.Parcelable
import java.util.Arrays
@MagicParcel
data class Test(val a: Array<String>) : 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
return true
}
override fun hashCode() = Arrays.hashCode(a)
}
fun box() = parcelTest { parcel ->
val first = Test(arrayOf("A", "B"))
first.writeToParcel(parcel, 0)
val bytes = parcel.marshall()
parcel.unmarshall(bytes, 0, bytes.size)
val first2 = readFromParcel<Test>(parcel)
assert(first == first2)
}
@@ -0,0 +1,76 @@
// WITH_RUNTIME
@file:JvmName("TestKt")
package test
import kotlinx.android.parcel.*
import android.os.Parcel
import android.os.Parcelable
import java.util.Arrays
@MagicParcel
data class Test(
val a: Array<String>,
val b: Array<String?>,
val c: IntArray,
val d: CharArray?,
val e: Array<IntArray>,
val f: Array<List<String>>,
val g: List<Array<String>>,
val h: Array<String>?
) : 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 (!Arrays.equals(b, other.b)) return false
if (!Arrays.equals(c, other.c)) return false
if (!Arrays.equals(d, other.d)) return false
if (!Arrays.deepEquals(e, other.e)) return false
if (!Arrays.equals(f, other.f)) return false
if (g.size != other.g.size) return false
if (!g.zip(other.g).all { (f, s) -> Arrays.equals(f, s) }) return false
if (!Arrays.equals(h, other.h)) return false
return true
}
override fun hashCode(): Int {
var result = Arrays.hashCode(a)
result = 31 * result + Arrays.hashCode(b)
result = 31 * result + Arrays.hashCode(c)
result = 31 * result + (d?.let { Arrays.hashCode(it) } ?: 0)
result = 31 * result + Arrays.hashCode(e)
result = 31 * result + Arrays.hashCode(f)
result = 31 * result + g.hashCode()
result = 31 * result + (h?.let { Arrays.hashCode(it) } ?: 0)
return result
}
}
fun box() = parcelTest { parcel ->
val first = Test(
a = arrayOf("A", "B", "C"),
b = arrayOf("A", null, "B"),
c = intArrayOf(1, 2, 3),
d = null,
e = arrayOf(intArrayOf(2, 4, 1), intArrayOf(10, 20)),
f = arrayOf(listOf("A"), listOf("B", "C")),
g = listOf(arrayOf("Z", "X"), arrayOf()),
h = arrayOf("")
)
first.writeToParcel(parcel, 0)
val bytes = parcel.marshall()
parcel.unmarshall(bytes, 0, bytes.size)
val first2 = readFromParcel<Test>(parcel)
assert(first == first2)
}
@@ -0,0 +1,41 @@
// WITH_RUNTIME
@file:JvmName("TestKt")
package test
import kotlinx.android.parcel.*
import android.os.Parcel
import android.os.Parcelable
@MagicParcel
data class BoxedTypes(
val boo: java.lang.Boolean,
val c: java.lang.Character,
val byt: java.lang.Byte,
val s: java.lang.Short,
val i: java.lang.Integer,
val f: java.lang.Float,
val l: java.lang.Long,
val d: java.lang.Double
) : Parcelable
fun box() = parcelTest { parcel ->
val first = BoxedTypes(
true as java.lang.Boolean,
'#' as java.lang.Character,
3.toByte() as java.lang.Byte,
10.toShort() as java.lang.Short,
-300 as java.lang.Integer,
-5.0f as java.lang.Float,
Long.MAX_VALUE as java.lang.Long,
3.14 as java.lang.Double)
first.writeToParcel(parcel, 0)
val bytes = parcel.marshall()
parcel.unmarshall(bytes, 0, bytes.size)
val first2 = readFromParcel<BoxedTypes>(parcel)
assert(first == first2)
}
@@ -0,0 +1,34 @@
// WITH_RUNTIME
@file:JvmName("TestKt")
package test
import kotlinx.android.parcel.*
import android.os.Parcel
import android.os.Parcelable
import android.os.Bundle
@MagicParcel
data class User(val a: Bundle) : Parcelable
fun box() = parcelTest { parcel ->
val test = User(Bundle().apply { putChar("A", 'c'); putByte("B", 40.toByte()); putString("C", "ABC") })
test.writeToParcel(parcel, 0)
val bytes = parcel.marshall()
parcel.unmarshall(bytes, 0, bytes.size)
val test2 = readFromParcel<User>(parcel)
assert(compareBundles(test.a, test2.a))
}
private fun compareBundles(first: Bundle, second: Bundle): Boolean {
if (first.size() != second.size()) return false
for (key in first.keySet()) {
if (first.get(key) != second.get(key)) return false
}
return true
}
@@ -0,0 +1,48 @@
// WITH_RUNTIME
// FULL_JDK
@file:JvmName("TestKt")
package test
import kotlinx.android.parcel.*
import android.os.Parcel
import android.os.Parcelable
import java.util.*
@MagicParcel
data class Test(
val a: List<String>,
val b: MutableList<String>,
val c: ArrayList<String>,
val d: LinkedList<String>,
val e: Set<String>,
val f: MutableSet<String>,
val g: TreeSet<String>,
val h: HashSet<String>,
val i: LinkedHashSet<String>
) : Parcelable
fun box() = parcelTest { parcel ->
val first = Test(
a = listOf("A"),
b = mutableListOf("B"),
c = ArrayList<String>().apply { this += "C" },
d = LinkedList<String>().apply { this += "D" },
e = setOf("E"),
f = mutableSetOf("F"),
g = TreeSet<String>().apply { this += "G" },
h = HashSet<String>().apply { this += "H" },
i = LinkedHashSet<String>().apply { this += "I" }
)
first.writeToParcel(parcel, 0)
val bytes = parcel.marshall()
parcel.unmarshall(bytes, 0, bytes.size)
val first2 = readFromParcel<Test>(parcel)
assert(first == first2)
assert((first.d as LinkedList<*>).size == 1)
assert((first2.h as HashSet<*>).size == 1)
}
@@ -0,0 +1,24 @@
// WITH_RUNTIME
@file:JvmName("TestKt")
package test
import kotlinx.android.parcel.*
import android.os.Parcel
import android.os.Parcelable
@MagicParcel
data class Test(val a: List<String>) : Parcelable
fun box() = parcelTest { parcel ->
val first = Test(listOf("A", "B"))
first.writeToParcel(parcel, 0)
val bytes = parcel.marshall()
parcel.unmarshall(bytes, 0, bytes.size)
val first2 = readFromParcel<Test>(parcel)
assert(first == first2)
}
@@ -0,0 +1,41 @@
// WITH_RUNTIME
@file:JvmName("TestKt")
package test
import kotlinx.android.parcel.*
import android.os.Parcel
import android.os.Parcelable
@MagicParcel
data class Test(
val a: List<String>,
val b: List<String?>,
val c: List<Int>,
val d: List<Int?>,
val e: List<List<String>?>,
val f: List<List<List<Int>>>
) : Parcelable
fun box() = parcelTest { parcel ->
val first = Test(
a = listOf("A", "B"),
b = listOf("A", null, "C"),
c = listOf(1, 2, 3),
d = listOf(1, null, 5),
e = listOf(listOf("A", "B"), listOf(), null),
f = listOf(listOf(listOf(1, 2), listOf(3)), listOf(listOf(5, 3)))
)
first.writeToParcel(parcel, 0)
val bytes = parcel.marshall()
parcel.unmarshall(bytes, 0, bytes.size)
val first2 = readFromParcel<Test>(parcel)
assert(first == first2)
assert(first2.a == listOf("A", "B"))
assert(first2.b.size == 3)
}
@@ -0,0 +1,40 @@
// WITH_RUNTIME
// FULL_JDK
@file:JvmName("TestKt")
package test
import kotlinx.android.parcel.*
import android.os.Parcel
import android.os.Parcelable
import java.util.*
@MagicParcel
data class Test(
val a: Map<String, String>,
val b: MutableMap<String, String>,
val c: HashMap<String, String>,
val d: LinkedHashMap<String, String>,
val e: TreeMap<String, String>
) : Parcelable
fun box() = parcelTest { parcel ->
val first = Test(
a = mapOf("A" to "B"),
b = mutableMapOf("A" to "B"),
c = HashMap<String, String>().apply { put("A", "B") },
d = LinkedHashMap<String, String>().apply { put("A", "B") },
e = TreeMap<String, String>().apply { put("A", "B") }
)
first.writeToParcel(parcel, 0)
val bytes = parcel.marshall()
parcel.unmarshall(bytes, 0, bytes.size)
val first2 = readFromParcel<Test>(parcel)
assert(first == first2)
assert((first.c as HashMap<*, *>).size == 1)
assert((first2.e as TreeMap<*, *>).size == 1)
}
@@ -0,0 +1,24 @@
// WITH_RUNTIME
@file:JvmName("TestKt")
package test
import kotlinx.android.parcel.*
import android.os.Parcel
import android.os.Parcelable
@MagicParcel
data class Test(val a: Map<String, String>) : Parcelable
fun box() = parcelTest { parcel ->
val first = Test(mapOf("A" to "B", "C" to "D"))
first.writeToParcel(parcel, 0)
val bytes = parcel.marshall()
parcel.unmarshall(bytes, 0, bytes.size)
val first2 = readFromParcel<Test>(parcel)
assert(first == first2)
}
@@ -0,0 +1,40 @@
// WITH_RUNTIME
@file:JvmName("TestKt")
package test
import kotlinx.android.parcel.*
import android.os.Parcel
import android.os.Parcelable
@MagicParcel
data class Test(
val a: Map<String, String>,
val b: Map<String?, String>,
val c: Map<String, String?>,
val d: Map<String, Map<Int, String>>,
val e: Map<Int?, List<String>>,
val f: Map<Boolean, Boolean>,
val g: Map<String, Map<String, Map<String, String>>>
) : Parcelable
fun box() = parcelTest { parcel ->
val first = Test(
a = mapOf("A" to "B", "C" to "D"),
b = mapOf("A" to "B", null to "D", "E" to "F"),
c = mapOf("A" to null, "C" to "D"),
d = mapOf("A" to mapOf(1 to "", 2 to "x")),
e = mapOf(1 to listOf("", ""), null to listOf()),
f = mapOf(true to false, false to true),
g = mapOf("A" to mapOf("B" to mapOf("C" to "D", "E" to "F")))
)
first.writeToParcel(parcel, 0)
val bytes = parcel.marshall()
parcel.unmarshall(bytes, 0, bytes.size)
val first2 = readFromParcel<Test>(parcel)
assert(first == first2)
}
@@ -0,0 +1,33 @@
// WITH_RUNTIME
@file:JvmName("TestKt")
package test
import kotlinx.android.parcel.*
import android.os.Parcel
import android.os.Parcelable
@MagicParcel
data class Test(
val str1: String,
val str2: String?,
val int1: Int,
val int2: Int?
) : Parcelable
fun box() = parcelTest { parcel ->
val first = Test("John", "Smith", 20, 30)
val second = Test("A", null, 20, null)
first.writeToParcel(parcel, 0)
second.writeToParcel(parcel, 0)
val bytes = parcel.marshall()
parcel.unmarshall(bytes, 0, bytes.size)
val first2 = readFromParcel<Test>(parcel)
val second2 = readFromParcel<Test>(parcel)
assert(first == first2)
assert(second == second2)
}
@@ -0,0 +1,28 @@
// WITH_RUNTIME
@file:JvmName("TestKt")
package test
import kotlinx.android.parcel.*
import android.os.Parcel
import android.os.Parcelable
@MagicParcel
data class Test(val a: String?) : Parcelable
fun box() = parcelTest { parcel ->
val first = Test("John")
val second = Test(null)
first.writeToParcel(parcel, 0)
second.writeToParcel(parcel, 0)
val bytes = parcel.marshall()
parcel.unmarshall(bytes, 0, bytes.size)
val first2 = readFromParcel<Test>(parcel)
val second2 = readFromParcel<Test>(parcel)
assert(first == first2)
assert(second == second2)
}
@@ -0,0 +1,38 @@
// WITH_RUNTIME
@file:JvmName("TestKt")
package test
import kotlinx.android.parcel.*
import android.os.Parcel
import android.os.Parcelable
@MagicParcel
data class PrimitiveTypes(
val boo: Boolean,
val c: Char,
val byt: Byte,
val s: Short,
val i: Int,
val f: Float,
val l: Long,
val d: Double
) : Parcelable
fun box() = parcelTest { parcel ->
val first = PrimitiveTypes(true, '#', 3.toByte(), 10.toShort(), -300, -5.0f, Long.MAX_VALUE, 3.14)
val second = PrimitiveTypes(false, '\n', Byte.MIN_VALUE, Short.MIN_VALUE, Int.MIN_VALUE, Float.POSITIVE_INFINITY,
Long.MAX_VALUE, Double.NEGATIVE_INFINITY)
first.writeToParcel(parcel, 0)
second.writeToParcel(parcel, 0)
val bytes = parcel.marshall()
parcel.unmarshall(bytes, 0, bytes.size)
val first2 = readFromParcel<PrimitiveTypes>(parcel)
val second2 = readFromParcel<PrimitiveTypes>(parcel)
assert(first == first2)
assert(second == second2)
}
@@ -0,0 +1,22 @@
// WITH_RUNTIME
@file:JvmName("TestKt")
package test
import kotlinx.android.parcel.*
import android.os.Parcel
import android.os.Parcelable
@MagicParcel
data class User(val firstName: String, val secondName: String, val age: Int) : Parcelable
fun box() = parcelTest { parcel ->
val user = User("John", "Smith", 20)
user.writeToParcel(parcel, 0)
val bytes = parcel.marshall()
parcel.unmarshall(bytes, 0, bytes.size)
val user2 = readFromParcel<User>(parcel)
assert(user == user2)
}
@@ -0,0 +1,70 @@
// WITH_RUNTIME
@file:JvmName("TestKt")
package test
import kotlinx.android.parcel.*
import android.os.Parcel
import android.os.Parcelable
import android.util.*
@MagicParcel
data class Data(val a: String, val b: String) : Parcelable
@MagicParcel
data class User(val a: SparseIntArray, val b: SparseLongArray, val c: SparseArray<Data>) : Parcelable
fun box() = parcelTest { parcel ->
val user = User(
a = SparseIntArray().apply { put(1, 5); put(100, -1); put(1000, 0) },
b = SparseLongArray().apply { put(3, 2); put(2, 3); put(10, 10) },
c = SparseArray<Data>().apply { put(1, Data("A", "B")); put(10, Data("C", "D")); put(105, Data("E", "")) }
)
user.writeToParcel(parcel, 0)
val bytes = parcel.marshall()
parcel.unmarshall(bytes, 0, bytes.size)
val user2 = readFromParcel<User>(parcel)
assert(compareSparseIntArrays(user.a, user2.a))
assert(compareSparseLongArrays(user.b, user2.b))
assert(compareSparseArrays(user.c, user2.c))
}
private fun compareSparseIntArrays(first: SparseIntArray, second: SparseIntArray): Boolean {
if (first === second) return true
if (first.size() != second.size()) return false
for (i in 0 until first.size()) {
if (first.keyAt(i) != second.keyAt(i)) return false
if (first.valueAt(i) != second.valueAt(i)) return false
}
return true
}
private fun compareSparseLongArrays(first: SparseLongArray, second: SparseLongArray): Boolean {
if (first === second) return true
if (first.size() != second.size()) return false
for (i in 0 until first.size()) {
if (first.keyAt(i) != second.keyAt(i)) return false
if (first.valueAt(i) != second.valueAt(i)) return false
}
return true
}
private fun compareSparseArrays(first: SparseArray<*>, second: SparseArray<*>): Boolean {
if (first === second) return true
if (first.size() != second.size()) return false
for (i in 0 until first.size()) {
if (first.keyAt(i) != second.keyAt(i)) return false
if (first.valueAt(i) != second.valueAt(i)) return false
}
return true
}
@@ -0,0 +1,36 @@
// WITH_RUNTIME
@file:JvmName("TestKt")
package test
import kotlinx.android.parcel.*
import android.os.Parcel
import android.os.Parcelable
import android.util.SparseBooleanArray
@MagicParcel
data class User(val a: SparseBooleanArray) : Parcelable
fun box() = parcelTest { parcel ->
val test = User(SparseBooleanArray().apply { put(1, false); put(5, true); put(1000, false) })
test.writeToParcel(parcel, 0)
val bytes = parcel.marshall()
parcel.unmarshall(bytes, 0, bytes.size)
val test2 = readFromParcel<User>(parcel)
assert(compareSparseBooleanArrays(test.a, test2.a))
}
private fun compareSparseBooleanArrays(first: SparseBooleanArray, second: SparseBooleanArray): Boolean {
if (first === second) return true
if (first.size() != second.size()) return false
for (i in 0 until first.size()) {
if (first.keyAt(i) != second.keyAt(i)) return false
if (first.valueAt(i) != second.valueAt(i)) return false
}
return true
}
@@ -0,0 +1,18 @@
package test
import android.os.Parcel
fun parcelTest(block: (Parcel) -> Unit): String {
val parcel = Parcel.obtain()
try {
block(parcel)
return "OK"
} finally {
parcel.recycle()
}
}
inline fun <reified T> readFromParcel(parcel: Parcel): T {
val creator = T::class.java.getDeclaredField("CREATOR").get(null)
return creator::class.java.getDeclaredMethod("createFromParcel", Parcel::class.java).invoke(creator, parcel) as T
}
@@ -0,0 +1,6 @@
// CURIOUS_ABOUT writeToParcel
import kotlinx.android.parcel.*
@MagicParcel
class Test(val names: List<List<List<String>>>)
@@ -0,0 +1,82 @@
public static class Test$CREATOR : java/lang/Object, android/os/Parcelable$Creator {
public void <init>()
public final Test createFromParcel(android.os.Parcel p0)
public final Test[] newArray(int p0)
}
public final class Test : java/lang/Object {
public final static Test$CREATOR CREATOR
private final java.util.List names
static void <clinit>()
public void <init>(java.util.List p0)
public final int describeContents()
public final java.util.List getNames()
public final void writeToParcel(android.os.Parcel p0, int p1) {
LABEL (L0)
ALOAD (1)
LDC (parcel)
INVOKESTATIC (kotlin/jvm/internal/Intrinsics, checkParameterIsNotNull, (Ljava/lang/Object;Ljava/lang/String;)V)
ALOAD (1)
ALOAD (0)
GETFIELD (names, Ljava/util/List;)
DUP_X1
INVOKEINTERFACE (java/util/Collection, size, ()I)
INVOKEVIRTUAL (android/os/Parcel, writeInt, (I)V)
INVOKEINTERFACE (java/util/Collection, iterator, ()Ljava/util/Iterator;)
LABEL (L1)
DUP
INVOKEINTERFACE (java/util/Iterator, hasNext, ()Z)
IFEQ (L2)
DUP
INVOKEINTERFACE (java/util/Iterator, next, ()Ljava/lang/Object;)
ALOAD (1)
SWAP
CHECKCAST
DUP_X1
INVOKEINTERFACE (java/util/Collection, size, ()I)
INVOKEVIRTUAL (android/os/Parcel, writeInt, (I)V)
INVOKEINTERFACE (java/util/Collection, iterator, ()Ljava/util/Iterator;)
LABEL (L3)
DUP
INVOKEINTERFACE (java/util/Iterator, hasNext, ()Z)
IFEQ (L4)
DUP
INVOKEINTERFACE (java/util/Iterator, next, ()Ljava/lang/Object;)
ALOAD (1)
SWAP
CHECKCAST
DUP_X1
INVOKEINTERFACE (java/util/Collection, size, ()I)
INVOKEVIRTUAL (android/os/Parcel, writeInt, (I)V)
INVOKEINTERFACE (java/util/Collection, iterator, ()Ljava/util/Iterator;)
LABEL (L5)
DUP
INVOKEINTERFACE (java/util/Iterator, hasNext, ()Z)
IFEQ (L6)
DUP
INVOKEINTERFACE (java/util/Iterator, next, ()Ljava/lang/Object;)
ALOAD (1)
SWAP
CHECKCAST
INVOKEVIRTUAL (android/os/Parcel, writeString, (Ljava/lang/String;)V)
GOTO (L5)
LABEL (L6)
POP
GOTO (L3)
LABEL (L4)
POP
GOTO (L1)
LABEL (L2)
POP
RETURN
LABEL (L7)
}
}
@@ -0,0 +1,10 @@
// CURIOUS_ABOUT writeToParcel
import android.util.Size
import kotlinx.android.parcel.*
@MagicParcel
class TestNullable(val a: Size?)
@MagicParcel
class TestNotNull(val a: Size)
@@ -0,0 +1,80 @@
public static class TestNotNull$CREATOR : java/lang/Object, android/os/Parcelable$Creator {
public void <init>()
public final TestNotNull createFromParcel(android.os.Parcel p0)
public final TestNotNull[] newArray(int p0)
}
public final class TestNotNull : java/lang/Object {
public final static TestNotNull$CREATOR CREATOR
private final android.util.Size a
static void <clinit>()
public void <init>(android.util.Size p0)
public final int describeContents()
public final android.util.Size getA()
public final void writeToParcel(android.os.Parcel p0, int p1) {
LABEL (L0)
ALOAD (1)
LDC (parcel)
INVOKESTATIC (kotlin/jvm/internal/Intrinsics, checkParameterIsNotNull, (Ljava/lang/Object;Ljava/lang/String;)V)
ALOAD (1)
ALOAD (0)
GETFIELD (a, Landroid/util/Size;)
INVOKEVIRTUAL (android/os/Parcel, writeSize, (Landroid/util/Size;)V)
RETURN
LABEL (L1)
}
}
public static class TestNullable$CREATOR : java/lang/Object, android/os/Parcelable$Creator {
public void <init>()
public final TestNullable createFromParcel(android.os.Parcel p0)
public final TestNullable[] newArray(int p0)
}
public final class TestNullable : java/lang/Object {
public final static TestNullable$CREATOR CREATOR
private final android.util.Size a
static void <clinit>()
public void <init>(android.util.Size p0)
public final int describeContents()
public final android.util.Size getA()
public final void writeToParcel(android.os.Parcel p0, int p1) {
LABEL (L0)
ALOAD (1)
LDC (parcel)
INVOKESTATIC (kotlin/jvm/internal/Intrinsics, checkParameterIsNotNull, (Ljava/lang/Object;Ljava/lang/String;)V)
ALOAD (1)
ALOAD (0)
GETFIELD (a, Landroid/util/Size;)
DUP
IFNULL (L1)
ALOAD (1)
LDC (1)
INVOKEVIRTUAL (android/os/Parcel, writeInt, (I)V)
INVOKEVIRTUAL (android/os/Parcel, writeSize, (Landroid/util/Size;)V)
GOTO (L2)
LABEL (L1)
POP
LDC (0)
INVOKEVIRTUAL (android/os/Parcel, writeInt, (I)V)
LABEL (L2)
RETURN
LABEL (L3)
}
}
@@ -0,0 +1,10 @@
// CURIOUS_ABOUT writeToParcel, createFromParcel, <clinit>
import kotlinx.android.parcel.*
import android.os.Parcelable
import java.io.Serializable
class SerializableSimple(val a: String, val b: String) : Serializable
@MagicParcel
class User(val notNull: SerializableSimple, val nullable: SerializableSimple) : Parcelable
@@ -0,0 +1,74 @@
public final class SerializableSimple : java/lang/Object, java/io/Serializable {
private final java.lang.String a
private final java.lang.String b
public void <init>(java.lang.String p0, java.lang.String p1)
public final java.lang.String getA()
public final java.lang.String getB()
}
public static class User$CREATOR : java/lang/Object, android/os/Parcelable$Creator {
public void <init>()
public final User createFromParcel(android.os.Parcel p0) {
LABEL (L0)
ALOAD (1)
LDC (in)
INVOKESTATIC (kotlin/jvm/internal/Intrinsics, checkParameterIsNotNull, (Ljava/lang/Object;Ljava/lang/String;)V)
NEW
DUP
ALOAD (1)
INVOKEVIRTUAL (android/os/Parcel, readSerializable, ()LSerializableSimple;)
ALOAD (1)
INVOKEVIRTUAL (android/os/Parcel, readSerializable, ()LSerializableSimple;)
INVOKESPECIAL (User, <init>, (LSerializableSimple;LSerializableSimple;)V)
ARETURN
LABEL (L1)
}
public final User[] newArray(int p0)
}
public final class User : java/lang/Object, android/os/Parcelable {
public final static User$CREATOR CREATOR
private final SerializableSimple notNull
private final SerializableSimple nullable
static void <clinit>() {
NEW
DUP
INVOKESPECIAL (User$CREATOR, <init>, ()V)
PUTSTATIC (CREATOR, LUser$CREATOR;)
RETURN
}
public void <init>(SerializableSimple p0, SerializableSimple p1)
public final int describeContents()
public final SerializableSimple getNotNull()
public final SerializableSimple getNullable()
public final void writeToParcel(android.os.Parcel p0, int p1) {
LABEL (L0)
ALOAD (1)
LDC (parcel)
INVOKESTATIC (kotlin/jvm/internal/Intrinsics, checkParameterIsNotNull, (Ljava/lang/Object;Ljava/lang/String;)V)
ALOAD (1)
ALOAD (0)
GETFIELD (notNull, LSerializableSimple;)
INVOKEVIRTUAL (android/os/Parcel, writeSerializable, (LSerializableSimple;)V)
ALOAD (1)
ALOAD (0)
GETFIELD (nullable, LSerializableSimple;)
INVOKEVIRTUAL (android/os/Parcel, writeSerializable, (LSerializableSimple;)V)
RETURN
LABEL (L1)
}
}
@@ -0,0 +1,7 @@
// CURIOUS_ABOUT writeToParcel, createFromParcel, <clinit>
import kotlinx.android.parcel.*
import android.os.Parcelable
@MagicParcel
class User(val firstName: String, val lastName: String, val age: Int, val isProUser: Boolean) : Parcelable
@@ -0,0 +1,82 @@
public static class User$CREATOR : java/lang/Object, android/os/Parcelable$Creator {
public void <init>()
public final User createFromParcel(android.os.Parcel p0) {
LABEL (L0)
ALOAD (1)
LDC (in)
INVOKESTATIC (kotlin/jvm/internal/Intrinsics, checkParameterIsNotNull, (Ljava/lang/Object;Ljava/lang/String;)V)
NEW
DUP
ALOAD (1)
INVOKEVIRTUAL (android/os/Parcel, readString, ()Ljava/lang/String;)
ALOAD (1)
INVOKEVIRTUAL (android/os/Parcel, readString, ()Ljava/lang/String;)
ALOAD (1)
INVOKEVIRTUAL (android/os/Parcel, readInt, ()I)
ALOAD (1)
INVOKEVIRTUAL (android/os/Parcel, readInt, ()I)
INVOKESPECIAL (User, <init>, (Ljava/lang/String;Ljava/lang/String;IZ)V)
ARETURN
LABEL (L1)
}
public final User[] newArray(int p0)
}
public final class User : java/lang/Object, android/os/Parcelable {
public final static User$CREATOR CREATOR
private final int age
private final java.lang.String firstName
private final boolean isProUser
private final java.lang.String lastName
static void <clinit>() {
NEW
DUP
INVOKESPECIAL (User$CREATOR, <init>, ()V)
PUTSTATIC (CREATOR, LUser$CREATOR;)
RETURN
}
public void <init>(java.lang.String p0, java.lang.String p1, int p2, boolean p3)
public final int describeContents()
public final int getAge()
public final java.lang.String getFirstName()
public final java.lang.String getLastName()
public final boolean isProUser()
public final void writeToParcel(android.os.Parcel p0, int p1) {
LABEL (L0)
ALOAD (1)
LDC (parcel)
INVOKESTATIC (kotlin/jvm/internal/Intrinsics, checkParameterIsNotNull, (Ljava/lang/Object;Ljava/lang/String;)V)
ALOAD (1)
ALOAD (0)
GETFIELD (firstName, Ljava/lang/String;)
INVOKEVIRTUAL (android/os/Parcel, writeString, (Ljava/lang/String;)V)
ALOAD (1)
ALOAD (0)
GETFIELD (lastName, Ljava/lang/String;)
INVOKEVIRTUAL (android/os/Parcel, writeString, (Ljava/lang/String;)V)
ALOAD (1)
ALOAD (0)
GETFIELD (age, I)
INVOKEVIRTUAL (android/os/Parcel, writeInt, (I)V)
ALOAD (1)
ALOAD (0)
GETFIELD (isProUser, Z)
INVOKEVIRTUAL (android/os/Parcel, writeInt, (I)V)
RETURN
LABEL (L1)
}
}
@@ -0,0 +1,6 @@
// CURIOUS_ABOUT writeToParcel
import kotlinx.android.parcel.*
@MagicParcel
class Test(val names: List<String>)
@@ -0,0 +1,50 @@
public static class Test$CREATOR : java/lang/Object, android/os/Parcelable$Creator {
public void <init>()
public final Test createFromParcel(android.os.Parcel p0)
public final Test[] newArray(int p0)
}
public final class Test : java/lang/Object {
public final static Test$CREATOR CREATOR
private final java.util.List names
static void <clinit>()
public void <init>(java.util.List p0)
public final int describeContents()
public final java.util.List getNames()
public final void writeToParcel(android.os.Parcel p0, int p1) {
LABEL (L0)
ALOAD (1)
LDC (parcel)
INVOKESTATIC (kotlin/jvm/internal/Intrinsics, checkParameterIsNotNull, (Ljava/lang/Object;Ljava/lang/String;)V)
ALOAD (1)
ALOAD (0)
GETFIELD (names, Ljava/util/List;)
DUP_X1
INVOKEINTERFACE (java/util/Collection, size, ()I)
INVOKEVIRTUAL (android/os/Parcel, writeInt, (I)V)
INVOKEINTERFACE (java/util/Collection, iterator, ()Ljava/util/Iterator;)
LABEL (L1)
DUP
INVOKEINTERFACE (java/util/Iterator, hasNext, ()Z)
IFEQ (L2)
DUP
INVOKEINTERFACE (java/util/Iterator, next, ()Ljava/lang/Object;)
ALOAD (1)
SWAP
CHECKCAST
INVOKEVIRTUAL (android/os/Parcel, writeString, (Ljava/lang/String;)V)
GOTO (L1)
LABEL (L2)
POP
RETURN
LABEL (L3)
}
}
@@ -0,0 +1,12 @@
// CURIOUS_ABOUT writeToParcel, createFromParcel
import kotlinx.android.parcel.*
import android.os.Parcelable
import android.util.Size
import android.util.SizeF
@MagicParcel
data class Test(val size: Size, val nullable: Size?) : Parcelable
@MagicParcel
data class TestF(val size: SizeF, val nullable: SizeF?) : Parcelable
@@ -0,0 +1,179 @@
public static class Test$CREATOR : java/lang/Object, android/os/Parcelable$Creator {
public void <init>()
public final Test createFromParcel(android.os.Parcel p0) {
LABEL (L0)
ALOAD (1)
LDC (in)
INVOKESTATIC (kotlin/jvm/internal/Intrinsics, checkParameterIsNotNull, (Ljava/lang/Object;Ljava/lang/String;)V)
LABEL (L1)
NEW
DUP
ALOAD (1)
INVOKEVIRTUAL (android/os/Parcel, readSize, ()Landroid/util/Size;)
ALOAD (1)
INVOKEVIRTUAL (android/os/Parcel, readInt, ()I)
IFEQ (L2)
ALOAD (1)
INVOKEVIRTUAL (android/os/Parcel, readSize, ()Landroid/util/Size;)
GOTO (L3)
LABEL (L2)
ACONST_NULL
LABEL (L3)
INVOKESPECIAL (Test, <init>, (Landroid/util/Size;Landroid/util/Size;)V)
ARETURN
LABEL (L4)
}
public final Test[] newArray(int p0)
}
public final class Test : java/lang/Object, android/os/Parcelable {
public final static Test$CREATOR CREATOR
private final android.util.Size nullable
private final android.util.Size size
static void <clinit>()
public void <init>(android.util.Size p0, android.util.Size p1)
public final android.util.Size component1()
public final android.util.Size component2()
public final Test copy(android.util.Size p0, android.util.Size p1)
public static Test copy$default(Test p0, android.util.Size p1, android.util.Size p2, int p3, java.lang.Object p4)
public final int describeContents()
public boolean equals(java.lang.Object p0)
public final android.util.Size getNullable()
public final android.util.Size getSize()
public int hashCode()
public java.lang.String toString()
public final void writeToParcel(android.os.Parcel p0, int p1) {
LABEL (L0)
ALOAD (1)
LDC (parcel)
INVOKESTATIC (kotlin/jvm/internal/Intrinsics, checkParameterIsNotNull, (Ljava/lang/Object;Ljava/lang/String;)V)
ALOAD (1)
ALOAD (0)
GETFIELD (size, Landroid/util/Size;)
INVOKEVIRTUAL (android/os/Parcel, writeSize, (Landroid/util/Size;)V)
ALOAD (1)
ALOAD (0)
GETFIELD (nullable, Landroid/util/Size;)
DUP
IFNULL (L1)
ALOAD (1)
LDC (1)
INVOKEVIRTUAL (android/os/Parcel, writeInt, (I)V)
INVOKEVIRTUAL (android/os/Parcel, writeSize, (Landroid/util/Size;)V)
GOTO (L2)
LABEL (L1)
POP
LDC (0)
INVOKEVIRTUAL (android/os/Parcel, writeInt, (I)V)
LABEL (L2)
RETURN
LABEL (L3)
}
}
public static class TestF$CREATOR : java/lang/Object, android/os/Parcelable$Creator {
public void <init>()
public final TestF createFromParcel(android.os.Parcel p0) {
LABEL (L0)
ALOAD (1)
LDC (in)
INVOKESTATIC (kotlin/jvm/internal/Intrinsics, checkParameterIsNotNull, (Ljava/lang/Object;Ljava/lang/String;)V)
LABEL (L1)
NEW
DUP
ALOAD (1)
INVOKEVIRTUAL (android/os/Parcel, readSizeF, ()Landroid/util/SizeF;)
ALOAD (1)
INVOKEVIRTUAL (android/os/Parcel, readInt, ()I)
IFEQ (L2)
ALOAD (1)
INVOKEVIRTUAL (android/os/Parcel, readSizeF, ()Landroid/util/SizeF;)
GOTO (L3)
LABEL (L2)
ACONST_NULL
LABEL (L3)
INVOKESPECIAL (TestF, <init>, (Landroid/util/SizeF;Landroid/util/SizeF;)V)
ARETURN
LABEL (L4)
}
public final TestF[] newArray(int p0)
}
public final class TestF : java/lang/Object, android/os/Parcelable {
public final static TestF$CREATOR CREATOR
private final android.util.SizeF nullable
private final android.util.SizeF size
static void <clinit>()
public void <init>(android.util.SizeF p0, android.util.SizeF p1)
public final android.util.SizeF component1()
public final android.util.SizeF component2()
public final TestF copy(android.util.SizeF p0, android.util.SizeF p1)
public static TestF copy$default(TestF p0, android.util.SizeF p1, android.util.SizeF p2, int p3, java.lang.Object p4)
public final int describeContents()
public boolean equals(java.lang.Object p0)
public final android.util.SizeF getNullable()
public final android.util.SizeF getSize()
public int hashCode()
public java.lang.String toString()
public final void writeToParcel(android.os.Parcel p0, int p1) {
LABEL (L0)
ALOAD (1)
LDC (parcel)
INVOKESTATIC (kotlin/jvm/internal/Intrinsics, checkParameterIsNotNull, (Ljava/lang/Object;Ljava/lang/String;)V)
ALOAD (1)
ALOAD (0)
GETFIELD (size, Landroid/util/SizeF;)
INVOKEVIRTUAL (android/os/Parcel, writeSizeF, (Landroid/util/SizeF;)V)
ALOAD (1)
ALOAD (0)
GETFIELD (nullable, Landroid/util/SizeF;)
DUP
IFNULL (L1)
ALOAD (1)
LDC (1)
INVOKEVIRTUAL (android/os/Parcel, writeInt, (I)V)
INVOKEVIRTUAL (android/os/Parcel, writeSizeF, (Landroid/util/SizeF;)V)
GOTO (L2)
LABEL (L1)
POP
LDC (0)
INVOKEVIRTUAL (android/os/Parcel, writeInt, (I)V)
LABEL (L2)
RETURN
LABEL (L3)
}
}