Here you can find the source of getGenericType(Class> clazz, int index)
public static Class<?> getGenericType(Class<?> clazz, int index)
//package com.java2s; //License from project: Apache License import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; public class Main { public static Class<?> getGenericType(Class<?> clazz, int index) { Type genType = clazz.getGenericSuperclass(); if (!(genType instanceof ParameterizedType)) { return Object.class; }//www .j a v a 2 s . co m Type[] params = ((ParameterizedType) genType).getActualTypeArguments(); if (index >= params.length || index < 0) { throw new RuntimeException("Index outof bounds"); } if (!(params[index] instanceof Class)) { return Object.class; } return (Class<?>) params[index]; } }