List of usage examples for com.badlogic.gdx.utils.reflect Method setAccessible
public void setAccessible(boolean accessible)
From source file:com.github.ykrasik.jaci.util.reflection.ReflectionUtils.java
License:Apache License
/** * Invokes the method, using the provided instance as 'this'. * Method must be no-args and have a return value of type {@code T}. * If the method is private, it will be made accessible outside of it's class. * * @param instance Instance to use as 'this' for invocation. * @param method Method to invoke.//w w w . j av a 2 s . c om * @param <T> Return type. * @return Result of invoking the no-args method. * @throws RuntimeException If an error occurred invoking the method. */ @SuppressWarnings("unchecked") public static <T> T invokeNoArgs(Object instance, Method method) { try { if (!method.isAccessible()) { method.setAccessible(true); } return (T) method.invoke(instance, NO_ARGS); } catch (final java.lang.Throwable $ex) { throw new RuntimeException($ex); } }