Code example for Method

Methods: isAccessible, setAccessible

0
        this.setter = setter;
        this.getter = getter;
        if (setter != null && !setter.isAccessible()) {
            setter.setAccessible(true);
        } 
        if (!getter.isAccessible()) {
            getter.setAccessible(true);
        } 
    } 
 
    @Override 
    public boolean isReadOnly() { 
        return setter == null;
    } 
 
    @Override 
    public Object get(Object instance)  throws AccessException {
        try { 
            return getter.invoke(instance);
        } catch (Exception e) {
            throw new AccessException("Failed to read field: "+getter, e);