am 0087f225: am 2f68a204: Merge "Check type resolution on declared methods and fields in ViewDebug" into lmp-mr1-dev

* commit '0087f2253ac8cbb4868fd27d71afbad32a103a75':
  Check type resolution on declared methods and fields in ViewDebug
This commit is contained in:
Alan Viverette
2014-10-17 17:27:41 +00:00
committed by Android Git Automerger

View File

@@ -1005,12 +1005,21 @@ public class ViewDebug {
return fields; return fields;
} }
final ArrayList<Field> foundFields = new ArrayList<Field>(); final ArrayList<Field> declaredFields = new ArrayList();
fields = klass.getDeclaredFields(); klass.getDeclaredFields(false, declaredFields);
int count = fields.length; final ArrayList<Field> foundFields = new ArrayList<Field>();
final int count = declaredFields.size();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
final Field field = fields[i]; final Field field = declaredFields.get(i);
// Ensure the field type can be resolved.
try {
field.getType();
} catch (NoClassDefFoundError e) {
continue;
}
if (field.isAnnotationPresent(ExportedProperty.class)) { if (field.isAnnotationPresent(ExportedProperty.class)) {
field.setAccessible(true); field.setAccessible(true);
foundFields.add(field); foundFields.add(field);
@@ -1039,12 +1048,22 @@ public class ViewDebug {
return methods; return methods;
} }
final ArrayList<Method> foundMethods = new ArrayList<Method>(); final ArrayList<Method> declaredMethods = new ArrayList();
methods = klass.getDeclaredMethods(); klass.getDeclaredMethods(false, declaredMethods);
int count = methods.length; final ArrayList<Method> foundMethods = new ArrayList<Method>();
final int count = declaredMethods.size();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
final Method method = methods[i]; final Method method = declaredMethods.get(i);
// Ensure the method return and parameter types can be resolved.
try {
method.getReturnType();
method.getParameterTypes();
} catch (NoClassDefFoundError e) {
continue;
}
if (method.getParameterTypes().length == 0 && if (method.getParameterTypes().length == 0 &&
method.isAnnotationPresent(ExportedProperty.class) && method.isAnnotationPresent(ExportedProperty.class) &&
method.getReturnType() != Void.class) { method.getReturnType() != Void.class) {