Here you can find the source of getGenericClass(Class clazz)
public static Class getGenericClass(Class clazz)
//package com.java2s; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; public class Main { public static Class getGenericClass(Class clazz) { return getGenericClass(clazz, 0); }//from ww w. j a v a2 s .c om public static Class getGenericClass(Class clazz, int index) { Type genType = clazz.getGenericSuperclass(); if (genType instanceof ParameterizedType) { Type[] params = ((ParameterizedType) genType).getActualTypeArguments(); if ((params != null) && (params.length >= (index - 1))) { return (Class) params[index]; } } return null; } }