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
This commit is contained in:
@@ -1247,9 +1247,6 @@ public final class Parcel {
|
|||||||
} else if (v instanceof Parcelable[]) {
|
} else if (v instanceof Parcelable[]) {
|
||||||
writeInt(VAL_PARCELABLEARRAY);
|
writeInt(VAL_PARCELABLEARRAY);
|
||||||
writeParcelableArray((Parcelable[]) v, 0);
|
writeParcelableArray((Parcelable[]) v, 0);
|
||||||
} else if (v instanceof Object[]) {
|
|
||||||
writeInt(VAL_OBJECTARRAY);
|
|
||||||
writeArray((Object[]) v);
|
|
||||||
} else if (v instanceof int[]) {
|
} else if (v instanceof int[]) {
|
||||||
writeInt(VAL_INTARRAY);
|
writeInt(VAL_INTARRAY);
|
||||||
writeIntArray((int[]) v);
|
writeIntArray((int[]) v);
|
||||||
@@ -1259,12 +1256,20 @@ public final class Parcel {
|
|||||||
} else if (v instanceof Byte) {
|
} else if (v instanceof Byte) {
|
||||||
writeInt(VAL_BYTE);
|
writeInt(VAL_BYTE);
|
||||||
writeInt((Byte) v);
|
writeInt((Byte) v);
|
||||||
} else if (v instanceof Serializable) {
|
|
||||||
// Must be last
|
|
||||||
writeInt(VAL_SERIALIZABLE);
|
|
||||||
writeSerializable((Serializable) v);
|
|
||||||
} else {
|
} 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user