Code example for Field

Methods: isAccessible, setAccessible

0
            throw new StubException(x.getMessage(), x);
        } 
    } 
 
    private static boolean makeFieldAccessible(Field field) {
        boolean accessible= field.isAccessible();
        if (!accessible) {
            field.setAccessible(true);
        } 
 
        return accessible;
    } 
 
    private static void returnToOriginalAccessibleState(Field field, boolean accessible) {
        if (!accessible) {
            field.setAccessible(false);
        } 
    } 
}