use of java.lang.reflect.AccessibleObject in project android_frameworks_base by crdroidandroid.
the class ViewDebug method getExportedPropertyMethods.
private static Method[] getExportedPropertyMethods(Class<?> klass) {
if (sMethodsForClasses == null) {
sMethodsForClasses = new HashMap<Class<?>, Method[]>(100);
}
if (sAnnotations == null) {
sAnnotations = new HashMap<AccessibleObject, ExportedProperty>(512);
}
final HashMap<Class<?>, Method[]> map = sMethodsForClasses;
Method[] methods = map.get(klass);
if (methods != null) {
return methods;
}
methods = klass.getDeclaredMethodsUnchecked(false);
final ArrayList<Method> foundMethods = new ArrayList<Method>();
for (final Method method : methods) {
// Ensure the method return and parameter types can be resolved.
try {
method.getReturnType();
method.getParameterTypes();
} catch (NoClassDefFoundError e) {
continue;
}
if (method.getParameterTypes().length == 0 && method.isAnnotationPresent(ExportedProperty.class) && method.getReturnType() != Void.class) {
method.setAccessible(true);
foundMethods.add(method);
sAnnotations.put(method, method.getAnnotation(ExportedProperty.class));
}
}
methods = foundMethods.toArray(new Method[foundMethods.size()]);
map.put(klass, methods);
return methods;
}
Aggregations