获取方法通用参数类型
//package com.nowjava; import java.lang.reflect.Method;/** 时 代 J a v a 公 众 号 提供 **/ import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; public class Main { public static Class<?> getMethodGenericParameterTypes(Method method, int paramIndex) { Class<?> literalType = method.getParameterTypes()[paramIndex]; Type genericType = method.getGenericParameterTypes()[paramIndex]; return chooseOneType(literalType, genericType); } static Class<?> chooseOneType(Class<?> literalType, Type genericType) { if (genericType instanceof ParameterizedType) { return digFromGenericType(genericType); }/* from 时代Java公众号 - nowjava.com*/ return literalType; } static Class<?> digFromGenericType(Type genericType) { Type[] typeArguments = ((ParameterizedType) genericType) .getActualTypeArguments(); Type type = typeArguments[0]; if (