Here you can find the source of getGenericClassFromMethodReturn(Method m)
public static Class getGenericClassFromMethodReturn(Method m) throws Exception
//package com.java2s; //License from project: Apache License import java.lang.reflect.Method; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; public class Main { public static Class getGenericClassFromMethodReturn(Method m) throws Exception { Type type = m.getGenericReturnType(); if (type instanceof ParameterizedType) { ParameterizedType pt = (ParameterizedType) type; return (Class) pt.getActualTypeArguments()[0]; }/*from w w w .j a v a 2 s. co m*/ return null; } }