From 97a72f6693a7bee3255b2307c6bb18f66669a36c Mon Sep 17 00:00:00 2001 From: Irfan Sheriff Date: Fri, 11 Jan 2013 10:45:51 -0800 Subject: [PATCH] Handle missing static for CREATOR I made a mistake of missing out on static for CREATOR on a Parcelable and it threw a NPE which was not obvious. We do not get NoSuchFieldException when CREATOR exists but is not static. Change-Id: Ib06f60797c00722075255d45e8189f8cebef9ae2 --- core/java/android/os/Parcel.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/java/android/os/Parcel.java b/core/java/android/os/Parcel.java index 788ab7401cc66..d69fef0b72494 100644 --- a/core/java/android/os/Parcel.java +++ b/core/java/android/os/Parcel.java @@ -2087,6 +2087,10 @@ public final class Parcel { + "Parcelable.Creator object called " + " CREATOR on class " + name); } + catch (NullPointerException e) { + throw new BadParcelableException("Parcelable protocol requires " + + "the CREATOR object to be static on class " + name); + } if (creator == null) { throw new BadParcelableException("Parcelable protocol requires a " + "Parcelable.Creator object called "