public class ThreadUtilsTest {
public static void main(String[] args) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("key", "hello world!");
ThreadUtilsTest t = new ThreadUtilsTest();
try {
t.invokeMethod("ThreadUtilsTest", "test", map);
} catch (Exception e) {
e.printStackTrace();
}
}
@SuppressWarnings("rawtypes")
public Object invokeMethod(String className, String methodName, Map params) throws Exception {
System.out.println(Class.forName("cn.hutool.core.thread.ThreadUtilsTest"));
Class<?> ownerClass = Class.forName(ThreadUtilsTest.class.getCanonicalName());
Object owner = ownerClass.newInstance();
Method method = ownerClass.getMethod(methodName, Map.class);
return method.invoke(owner, params);
}
public String test(Map<String, Object> map) {
System.out.println("success");
System.out.print(map.get("key"));
return "success";
}
}
class cn.hutool.core.thread.ThreadUtilsTest
success
hello world!