Suppose that I have a .class file, can I get all the methods included in that class ?
public static Method[] getAccessibleMethods(Class clazz) {
List result = new ArrayList();
while (clazz != null) {
for (Method method : clazz.getDeclaredMethods()) {
int modifiers = method.getModifiers();
if (Modifier.isPublic(modifiers) || Modifier.isProtected(modifiers)) {
result.add(method);
}
}
clazz = clazz.getSuperclass();
}
return result.toArray(new Method[result.size()]);
}