mvvmfx/src/main/java/de/saxsys/mvvmfx/internal/viewloader/ReflectionUtils.java
public static <T> T accessMember(final AccessibleObject member, final Callable<T> callable, String errorMessage) {
		if (callable == null) {
			return null;
		}
		return AccessController.doPrivileged((PrivilegedAction<T>) () -> {
			boolean wasAccessible = member.isAccessible();
			try {
				member.setAccessible(true);
				return callable.call();
			} catch (Exception exception) {
				throw new IllegalStateException(errorMessage, exception);
			} finally {
				member.setAccessible(wasAccessible);
			}
		});
	}
public static <T> T accessMember(final AccessibleObject member, final Callable<T> callable, String errorMessage) {
		if (callable == null) {
			return null;
		}
		return AccessController.doPrivileged((PrivilegedAction<T>) () -> {
			boolean wasAccessible = member.isAccessible();
			try {
				member.setAccessible(true);
				return callable.call();
			} catch (Exception exception) {
				throw new IllegalStateException(errorMessage, exception);
			} finally {
				member.setAccessible(wasAccessible);
			}
		});
	}
public static < T > T accessMember ( final AccessibleObject member , final Callable < T > callable , String errorMessage ) { if ( callable == null ) { return null ; } return AccessController . doPrivileged ( ( PrivilegedAction < T > ) ( ) -> { boolean wasAccessible = member . isAccessible ( ) ; try { member . setAccessible ( true ) ; return callable . call ( ) ; } catch ( Exception exception ) { throw new IllegalStateException ( errorMessage , exception ) ; } finally { member . setAccessible ( wasAccessible ) ; } } ) ; }
Helper method to execute a callback on a given member. This method encapsulates the error handling logic and the
handling of accessibility of the member.

After the callback is executed the accessibility of the member will be reset to the originally state.

@param member
the member that is made accessible to run the callback
@param callable
the callback that will be executed.
@param errorMessage
the error message that is used in the exception when something went wrong.

@return the return value of the given callback.

@throws IllegalStateException
when something went wrong.
Helper method to execute a callback on a given member . This method encapsulates the error handling logic and the handling of accessibility of the member .