Hello,
I use library BeanUtils v 1.7.0. NoSuchMethodException is thrown when public
property of non public class is accessed.
This happens because the following check fails in getAccessibleMethod(Method
method) of MethodUtils class:
// If the declaring class is public, we are done
Class clazz = method.getDeclaringClass();
if (Modifier.isPublic(clazz.getModifiers())) {
return (method);
}
The code below can be used for tests. Is this the way framework is expected
to work?
public class Main {
public static void main(String... args) {
ABean abean = new ABean();
try {
System.out.println(PropertyUtils.getSimpleProperty(abean,
"name"));
} catch (Exception e) {
e.printStackTrace();
}
}
static class ABean {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
}
Thanks,
Andriy