Here you can find the source of getMethodGenericReturnType(Method method, int index)
public static Class getMethodGenericReturnType(Method method, int index)
//package com.java2s; //License from project: Open Source License import java.lang.reflect.*; public class Main { public static Class getMethodGenericReturnType(Method method, int index) { return getGenericType(method.getGenericReturnType(), index); }// w ww .j a va2s . c o m 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); } return (Class) typeArguments[index]; } return (Class) returnType; } }