Here you can find the source of getGenericSuperType(Class clz, int index)
public static Class getGenericSuperType(Class clz, int index)
//package com.java2s; //License from project: Open Source License import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; public class Main { public static Class getGenericSuperType(Class clz, int index) { Class[] clzs = getAllGenericSuperType(clz); if (index < 0 || index > clzs.length - 1) return Object.class; return clzs[index]; }/* w w w . j a v a 2 s . c o m*/ public static Class[] getAllGenericSuperType(Class clz) { if (clz == null) return new Class[] { Object.class }; Type genericType = clz.getGenericSuperclass(); if (!(genericType instanceof ParameterizedType)) return new Class[] { Object.class }; Type[] params = ((ParameterizedType) genericType).getActualTypeArguments(); Class[] clzs = new Class[params.length]; for (int i = 0; i < params.length; i++) if (params[i] instanceof Class) clzs[i] = (Class) params[i]; else clzs[i] = Object.class; return clzs; } }