Here you can find the source of getGenericType(Type type)
public static Class<?> getGenericType(Type type)
//package com.java2s; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; public class Main { public static Class<?> getGenericType(Type type) { return getGenericType(type, 0); }//from w ww. j a v a2 s . com public static Class<?> getGenericType(Type type, int index) { if (index < 0) { throw new ArrayIndexOutOfBoundsException(index); } if (type instanceof ParameterizedType) { ParameterizedType pgrt = (ParameterizedType) type; return (Class<?>) pgrt.getActualTypeArguments()[index]; } else { throw new ClassCastException(String.format("the genericReturnType[%d]: %s is not a ParameterizedType!", index, type == null ? "null" : type.toString())); } } }