Here you can find the source of invokeStatic(final String className, final String methodName, final I argument)
@SuppressWarnings("unchecked") public static <I, O> O invokeStatic(final String className, final String methodName, final I argument)
//package com.java2s; //License from project: Apache License import java.lang.reflect.Method; public class Main { @SuppressWarnings("unchecked") public static <I, O> O invokeStatic(final String className, final String methodName, final I argument) { try {// w w w. jav a 2s. c o m final Class<?> clazz = Class.forName(className); final Class<?> argumentClass = argument.getClass(); final Method method = clazz.getDeclaredMethod(methodName, argumentClass); return (O) method.invoke(null, argument); } catch (final Exception ex) { return handleReflectionException(ex); } } public static <T> T handleReflectionException(final Throwable ex) { if (ex instanceof RuntimeException) { throw (RuntimeException) ex; } else if (ex instanceof Error) { throw (Error) ex; } throw new RuntimeException(ex); } }