am 9bf1a139: am 72c5e376: am ba1ae3af: am 42786418: Don\'t instantiate non-Fragments in Fragment.instantiate

* commit '9bf1a1394852ad773d590d1cc60c5e50be8cb1b9':
  Don't instantiate non-Fragments in Fragment.instantiate
This commit is contained in:
Amith Yamasani
2013-09-27 11:20:20 -07:00
committed by Android Git Automerger

View File

@ -580,6 +580,10 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene
if (clazz == null) {
// Class not found in the cache, see if it's real, and try to add it
clazz = context.getClassLoader().loadClass(fname);
if (!Fragment.class.isAssignableFrom(clazz)) {
throw new InstantiationException("Trying to instantiate a class " + fname
+ " that is not a Fragment", new ClassCastException());
}
sClassMap.put(fname, clazz);
}
Fragment f = (Fragment)clazz.newInstance();