private static Class getActualTypeArgument(Method method)
throws ClassNotFoundException {
Type[] paramTypeList = method.getGenericParameterTypes();
if (paramTypeList[0] instanceof ParameterizedType) {
Type[] types = ((ParameterizedType) paramTypeList[0])
.getActualTypeArguments();
Type type = types[0];
String classType = type.toString().replaceAll("class ", "");
return Class.forName(classType);
}
return null;
}
获取方法中的范型参数的类型
最新推荐文章于 2021-07-12 21:03:04 发布