Here you can find the source of getGenericType(Type returnType, int index)
public static Class getGenericType(Type returnType, int index)
//package com.java2s; //License from project: Open Source License import java.lang.reflect.*; public class Main { public static Class getGenericType(Type returnType, int index) { if (returnType instanceof ParameterizedType) { ParameterizedType type = (ParameterizedType) returnType; Type[] typeArguments = type.getActualTypeArguments(); if (index >= typeArguments.length || index < 0) { throw new RuntimeException("invalid index : " + index); }/* www. j ava 2 s.c o m*/ return (Class) typeArguments[index]; } return (Class) returnType; } }