I will use a specific example to make it easier to understand.
Rather than using:
Annotation[] annotations = method.getAnnotations();
I’d like to be able to get an array of the class types associated with each annotation:
Class<?>[] annotationClasses = method.getAnnotationTypes();
Is there a way to override the Method class and add my custom method that will use getAnnotations to collect the annotations, but return the class type instead of an Annotation type?
There is no way to do exactly what you are requesting.
Methodis final and can not be extended.However, you could do