Here you can find the source of getMethodGenericParameterTypes(Method method, int index)
public static List<Class> getMethodGenericParameterTypes(Method method, int index)
//package com.java2s; //License from project: Apache License import java.lang.reflect.Method; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; public class Main { public static List<Class> getMethodGenericParameterTypes(Method method, int index) { List<Class> results = new ArrayList<Class>(); Type[] genericParameterTypes = method.getGenericParameterTypes(); if (index >= genericParameterTypes.length || index < 0) { throw new IllegalArgumentException("index " + (index < 0 ? " must > 0 " : " over total arguments")); }/*from w w w .ja v a 2 s . com*/ Type genericParameterType = genericParameterTypes[index]; if (genericParameterType instanceof ParameterizedType) { ParameterizedType aType = (ParameterizedType) genericParameterType; Type[] parameterArgTypes = aType.getActualTypeArguments(); for (Type parameterArgType : parameterArgTypes) { Class parameterArgClass = (Class) parameterArgType; results.add(parameterArgClass); } return results; } return results; } public static List<Class> getMethodGenericParameterTypes(Method method) { return getMethodGenericParameterTypes(method, 0); } }