Menu

#9 Unable to understand IllegalAccessException's origin

Unstable_(example)
open
nobody
debug (1)
5
2014-06-08
2014-03-10
Zied Hamdi
No

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());
    }
}

Discussion


Log in to post a comment.

MongoDB Logo MongoDB