Here you can find the source of getGenericParamTypes(Type genericType)
public static Class<?>[] getGenericParamTypes(Type genericType)
//package com.java2s; //License from project: Open Source License import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.*; public class Main { public static Class<?>[] getGenericParamTypes(Type genericType) { Objects.requireNonNull(genericType, "Generic type is NULL!"); try {/* w w w .j av a 2s . c om*/ if (genericType instanceof ParameterizedType) { Type[] genericTypes = ((ParameterizedType) genericType).getActualTypeArguments(); Class<?>[] result = new Class<?>[genericTypes.length]; for (int i = 0; i < genericTypes.length; i++) { if (genericTypes[i] instanceof Class<?>) { result[i] = (Class<?>) genericTypes[i]; } else if (genericTypes[i] instanceof ParameterizedType) { Type rawType = ((ParameterizedType) genericTypes[i]).getRawType(); result[i] = (Class<?>) rawType; } else { // ignore it } } return result; } } catch (Exception e) { ; // ignore it } return new Class<?>[0]; } }