Android: Is reflection bad?
I’m new to Android, but I’ve done quite a bit of server-side Java.
I’m reading about Intents, specifically the difference between sending extra data (classes) via Serializable
and Parcelable
. Serializeable
doesn’t perform well and there seems to be a consensus that Parcelable
is preferred. In some places, I see it saying Serializeable
is bad because it uses reflection.
This leads me to a couple of questions:
Is reflex generally considered bad? Should I avoid using any libraries that rely heavily on reflection? For example, if I need JSON deserialization (from some web service), should I not use Jackson or Gson? Is org.json garbage really a “best practice” in the Android space?
If I really should avoid reflection (hence
Serializable
), is there any alternative to the ugly, heavy boilerplateParcelable
? Intents are all explicit, I don’t broadcast them outside the app. I guess I don’t understand why in-process messaging can’t just pass a reference to an object in an intent.