Here you can find the source of getGenericFieldClassType(Class> clz, String propertyName)
public static Class<?> getGenericFieldClassType(Class<?> clz, String propertyName) throws NoSuchFieldException, SecurityException
//package com.java2s; //License from project: Apache License import java.lang.reflect.Field; import java.lang.reflect.ParameterizedType; public class Main { public static Class<?> getGenericFieldClassType(Class<?> clz, String propertyName) throws NoSuchFieldException, SecurityException { Field field = clz.getDeclaredField(propertyName); field.setAccessible(true);//from ww w . j a v a 2 s. c o m ParameterizedType parameterizedType = (ParameterizedType) field.getGenericType(); Class<?> genericClass = (Class<?>) parameterizedType.getActualTypeArguments()[0]; return genericClass; } }