Java 在around avice,如何获得';类型参数';建议方法的一个参数

Java 在around avice,如何获得';类型参数';建议方法的一个参数,java,spring,reflection,spring-aop,type-parameter,Java,Spring,Reflection,Spring Aop,Type Parameter,使用SpringAOP,我编写了一个方面,其中包含一个around建议,可以截取任何用@MyAnnotation注释的方法。假设拦截的方法声明如下: @MyAnnotation public String someMethod(ArrayList<Integer> arrList) {...} 但注销的只是一个E。我该怎么做才能打印出java.lang.Integer?试试这个: @Around("@annotation(MyAnnotation)") public Object

使用SpringAOP,我编写了一个方面,其中包含一个around建议,可以截取任何用
@MyAnnotation
注释的方法。假设拦截的方法声明如下:

@MyAnnotation
public String someMethod(ArrayList<Integer> arrList) {...}
但注销的只是一个
E
。我该怎么做才能打印出
java.lang.Integer

试试这个:

@Around("@annotation(MyAnnotation)")
public Object advice(ProceedingJoinPoint pjp) throws Throwable {
    Method method = ((MethodSignature) pjp.getSignature()).getMethod();
    Type[] genericParamsClass = method.getGenericParameterTypes();

    logger.info(((ParameterizedType) genericParamsClass[0]).getActualTypeArguments()[0]);
    ...
}

请参阅此注释:如果您有时间,请解释
方法.getGenericParameterTypes()
返回的确切内容。我试图找出
类型
之间的区别,据我所知,
类型
的泛化,其他
类型
接口
数组
原语
。但是我无法确定
方法.getGenericParameterTypes()
返回的
类型是什么类型的
,它可以包含泛型参数为
java.lang.Integer
的信息。非常感谢。
@Around("@annotation(MyAnnotation)")
public Object advice(ProceedingJoinPoint pjp) throws Throwable {
    Method method = ((MethodSignature) pjp.getSignature()).getMethod();
    Type[] genericParamsClass = method.getGenericParameterTypes();

    logger.info(((ParameterizedType) genericParamsClass[0]).getActualTypeArguments()[0]);
    ...
}