Unable to understand IllegalAccessException's origin
Brought to you by:
charliehubbard
Hi,
There is an issue when the lib is unable to access a field, the error message is unclear since it doesn't specify which field is problematic
I had to modify the class BeanProperty (line 104) to the following to understand what's happening, an exception dedicated for the purpose that encapsulates the two low level exceptions would be welcome instead of rethrowing an IllegalAccessException as I did here :
public Object getValue(Object instance) throws InvocationTargetException, IllegalAccessException {
try {
Method rm = getReadMethod();
if (rm != null) {
return rm.invoke(instance, (Object[]) null);
} else if (property != null) {
return property.get(instance);
} else {
return null;
}
} catch (IllegalAccessException | InvocationTargetException ex) {
throw new IllegalAccessException("Cannot access property " + property.getName() + " : " + ex.getMessage());
}
}