是的,有可能。表示这种结构的反射类型称为
AnnotatedParameterizedType。这是如何获取注释的示例:
// get the email field Field emailAddressField = MyClass.class.getDeclaredField("emailAddresses");// the field's type is both parameterized and annotated,// cast it to the right type representationAnnotatedParameterizedType annotatedParameterizedType = (AnnotatedParameterizedType) emailAddressField.getAnnotatedType();// get all type parametersAnnotatedType[] annotatedActualTypeArguments = annotatedParameterizedType.getAnnotatedActualTypeArguments();// the String parameter which contains the annotationAnnotatedType stringParameterType = annotatedActualTypeArguments[0];// The actual annotationAnnotation emailAnnotation = stringParameterType.getAnnotations()[0];System.out.println(emailAnnotation); // @Email()


