ReflectUtil { public static String getMethodDesc(Method method) { String methodParamDesc = getMethodParamDesc(method); return getMethodDesc(method.getName(), methodParamDesc); }  static String getMethodParamDesc(Method method); static String getMethodDesc(Method method); static String getMethodDesc(String methodName, String paramDesc); static Class<?>[] forNames(String classList); static Class<?> forName(String className); static String getName(Class<?> clz); static Class<?> getPrimitiveClass(String name); static List<Method> getPublicMethod(Class<?> clz); static Object getEmptyObject(Class<?> returnType); static final String PARAM_CLASS_SPLIT; static final String EMPTY_PARAM; }
@Test public void testReflect(){ Method method; try { method = ReflectTest.class.getMethod("getByte", byte.class); assertEquals("getByte(byte)", ReflectUtil.getMethodDesc(method)); method = ReflectTest.class.getMethod("get"); assertEquals("get(void)", ReflectUtil.getMethodDesc(method)); method = ReflectTest.class.getMethod("getList", List.class); assertEquals("getList(java.util.List)", ReflectUtil.getMethodDesc(method)); method = ReflectTest.class.getMethod("getMap", Map.class); assertEquals("getMap(java.util.Map)", ReflectUtil.getMethodDesc(method)); method = ReflectTest.class.getMethod("getStringArray", String[].class); assertEquals("getStringArray(java.lang.String[])", ReflectUtil.getMethodDesc(method)); method = ReflectTest.class.getMethod("getIntArray", int[].class); assertEquals("getIntArray(int[])", ReflectUtil.getMethodDesc(method)); } catch (Exception e) { assertTrue(false); } }