Here you can find the source of getGenericType(Class> type)
public static <T> T getGenericType(Class<?> type)
//package com.java2s; //License from project: Open Source License import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; public class Main { public static <T> T getGenericType(Class<?> type) { assert type != null; ParameterizedType genericSuperclass = (ParameterizedType) type.getGenericSuperclass(); Type[] actualTypeArguments = genericSuperclass.getActualTypeArguments(); return (T) actualTypeArguments[0]; }/* ww w . j a va 2s . c om*/ }