public static <R> R callFunc(Object instance, Class<?> type, Class<R> returnType,
			String methodName, Class<?>[] types, Object... args) {
		try {
			final Method method = type.getDeclaredMethod(methodName, types);
			method.setAccessible(true);
			return returnType.cast(method.invoke(instance, args));
		} catch (Exception exception) {
			throw new Error(exception);
		}
	}
public static < R > R callFunc ( Object instance , Class < ? > type , Class < R > returnType , String methodName , Class < ? > [ ] types , Object ... args ) { try { final Method method = type . getDeclaredMethod ( methodName , types ) ; method . setAccessible ( true ) ; return returnType . cast ( method . invoke ( instance , args ) ) ; } catch ( Exception exception ) { throw new Error ( exception ) ; } }
Call the method.

@param <R> the type of the returned value.
@param instance the instance to call on.
@param type the type.
@param returnType the type of the returned value.
@param methodName the name of the method.
@param types the types of the parameters.
@param args the values of the arguments.
@return the value.