获取方法通用返回类型
//package com.nowjava;//from NowJava.com - 时代Java import java.lang.reflect.Method; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; public class Main { public static Class<?> getMethodGenericReturnType(Method method) { return chooseOneType(method.getReturnType(), method.getGenericReturnType()); } static Class<?> chooseOneType(Class<?> literalType, Type genericType) { if (genericType instanceof ParameterizedType) { return digFromGenericType(genericType); } return literalType; } /** from N o w J a v a . c o m**/ static Class<?> digFromGenericType(Type genericType) { Type[] typeArguments = ((ParameterizedType) genericType) .getActualTypeArguments(); Type type = typeArguments[0]; if (type