反射中获取泛型参数信息

        Method m = null;
        try {
            m = ReflectionClass.class.getMethod("test", Map.class, List.class);
            Type[] mType = m.getGenericParameterTypes();

            for(Type t : mType){
                for(Type p :((ParameterizedType)t).getActualTypeArguments()){
                    System.out.println(p);
                }

            }
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }

你可能感兴趣的:(java学习笔记)