获取父类参数类型工具类

package com.panchan.tsmese.utils;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

/**
 * @Description:TODO
 * @version 1.0
 * @since JDK1.8
 * @author 
 * @Created on 2018年9月19日
 */

public class FatherReflectUtils {

    /**
     * 获取父类的参数类型方法
     * @param clazz
     * @param index
     * @return
     * @throws InstantiationException
     * @throws IllegalAccessException
     */
    @SuppressWarnings("rawtypes")
    public static Class getSuperClassParamType(Class<?> clazz, int index) throws InstantiationException, IllegalAccessException {
        Type sType = clazz.getGenericSuperclass();
        Type[] generics = ((ParameterizedType) sType).getActualTypeArguments();
        Class<?> mClass = (Class<?>) (generics[index]);
        
        return mClass;
    }
    
}
原文地址:https://www.cnblogs.com/huyanlon/p/10641332.html