Java – Android: Is reflection bad?

Android: Is reflection bad?… here is a solution to the problem.

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:

  1. 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?

  2. If I really should avoid reflection (hence Serializable), is there any alternative to the ugly, heavy boilerplate Parcelable? 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.

Related Problems and Solutions