summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Paul Duffin <paulduffin@google.com> 2014-02-12 23:01:39 +0000
committer Android Git Automerger <android-git-automerger@android.com> 2014-02-12 23:01:39 +0000
commit5ea06c59be1f7a0495378f703562ee02eaad99d8 (patch)
tree0210c5c0450c74abc1f6116b9fafe810b768651f
parent5a42b10baa1c852558ac45276e005a2667d9227b (diff)
parent4de9111819638b70dd6fb58094d7a61477fc59da (diff)
am 4de91118: am 0741e11c: am 75d67c6a: am d562a9b5: Merge "Improve Parcel\'s handling of non-primitive arrays"
* commit '4de9111819638b70dd6fb58094d7a61477fc59da': Improve Parcel's handling of non-primitive arrays
-rw-r--r--core/java/android/os/Parcel.java21
1 files changed, 13 insertions, 8 deletions
diff --git a/core/java/android/os/Parcel.java b/core/java/android/os/Parcel.java
index 0deaea6cc679..c3f48078eceb 100644
--- a/core/java/android/os/Parcel.java
+++ b/core/java/android/os/Parcel.java
@@ -1247,9 +1247,6 @@ public final class Parcel {
} else if (v instanceof Parcelable[]) {
writeInt(VAL_PARCELABLEARRAY);
writeParcelableArray((Parcelable[]) v, 0);
- } else if (v instanceof Object[]) {
- writeInt(VAL_OBJECTARRAY);
- writeArray((Object[]) v);
} else if (v instanceof int[]) {
writeInt(VAL_INTARRAY);
writeIntArray((int[]) v);
@@ -1259,12 +1256,20 @@ public final class Parcel {
} else if (v instanceof Byte) {
writeInt(VAL_BYTE);
writeInt((Byte) v);
- } else if (v instanceof Serializable) {
- // Must be last
- writeInt(VAL_SERIALIZABLE);
- writeSerializable((Serializable) v);
} else {
- throw new RuntimeException("Parcel: unable to marshal value " + v);
+ Class<?> clazz = v.getClass();
+ if (clazz.isArray() && clazz.getComponentType() == Object.class) {
+ // Only pure Object[] are written here, Other arrays of non-primitive types are
+ // handled by serialization as this does not record the component type.
+ writeInt(VAL_OBJECTARRAY);
+ writeArray((Object[]) v);
+ } else if (v instanceof Serializable) {
+ // Must be last
+ writeInt(VAL_SERIALIZABLE);
+ writeSerializable((Serializable) v);
+ } else {
+ throw new RuntimeException("Parcel: unable to marshal value " + v);
+ }
}
}