diff --git a/org.springframework.core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java b/org.springframework.core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java index ebbcd83fd23..754ed3f57f9 100644 --- a/org.springframework.core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java +++ b/org.springframework.core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java @@ -50,6 +50,7 @@ public abstract class AnnotationUtils { /** The attribute name for annotations with a single element */ static final String VALUE = "value"; + /** * Get all {@link Annotation Annotations} from the supplied {@link Method}. *

Correctly handles bridge {@link Method Methods} generated by the compiler. @@ -135,14 +136,16 @@ public abstract class AnnotationUtils { } /** - * Find a single {@link Annotation} of annotationType from the supplied {@link Class}, traversing its - * interfaces and super classes if no annotation can be found on the given class itself.

This method explicitly - * handles class-level annotations which are not declared as {@link java.lang.annotation.Inherited inherited} as - * well as annotations on interfaces.

The algorithm operates as follows: Searches for an annotation on the given - * class and returns it if found. Else searches all interfaces that the given class declares, returning the annotation - * from the first matching candidate, if any. Else proceeds with introspection of the superclass of the given class, - * checking the superclass itself; if no annotation found there, proceeds with the interfaces that the superclass - * declares. Recursing up through the entire superclass hierarchy if no match is found. + * Find a single {@link Annotation} of annotationType from the supplied {@link Class}, + * traversing its interfaces and super classes if no annotation can be found on the given class itself. + *

This method explicitly handles class-level annotations which are not declared as + * {@link Inherited inherited} as well as annotations on interfaces. + *

The algorithm operates as follows: Searches for an annotation on the given class and returns + * it if found. Else searches all interfaces that the given class declares, returning the annotation + * from the first matching candidate, if any. Else proceeds with introspection of the superclass + * of the given class, checking the superclass itself; if no annotation found there, proceeds + * with the interfaces that the superclass declares. Recursing up through the entire superclass + * hierarchy if no match is found. * @param clazz the class to look for annotations on * @param annotationType the annotation class to look for * @return the annotation found, or null if none found @@ -175,18 +178,21 @@ public abstract class AnnotationUtils { } /** - * Find the first {@link Class} in the inheritance hierarchy of the specified clazz (including the - * specified clazz itself) which declares an annotation for the specified annotationType, or - * null if not found. If the supplied clazz is null, null will be - * returned.

If the supplied clazz is an interface, only the interface itself will be checked; the - * inheritance hierarchy for interfaces will not be traversed.

The standard {@link Class} API does not provide a - * mechanism for determining which class in an inheritance hierarchy actually declares an {@link Annotation}, so we - * need to handle this explicitly. + * Find the first {@link Class} in the inheritance hierarchy of the specified clazz + * (including the specified clazz itself) which declares an annotation for the + * specified annotationType, or null if not found. If the supplied + * clazz is null, null will be returned. + *

If the supplied clazz is an interface, only the interface itself will be checked; + * the inheritance hierarchy for interfaces will not be traversed. + *

The standard {@link Class} API does not provide a mechanism for determining which class + * in an inheritance hierarchy actually declares an {@link Annotation}, so we need to handle + * this explicitly. * @param annotationType the Class object corresponding to the annotation type - * @param clazz the Class object corresponding to the class on which to check for the annotation, or - * null. - * @return the first {@link Class} in the inheritance hierarchy of the specified clazz which - * declares an annotation for the specified annotationType, or null if not found. + * @param clazz the Class object corresponding to the class on which to check for the annotation, + * or null + * @return the first {@link Class} in the inheritance hierarchy of the specified clazz + * which declares an annotation for the specified annotationType, or null + * if not found * @see Class#isAnnotationPresent(Class) * @see Class#getDeclaredAnnotations() */ diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/annotation/AnnotationMethodHandlerAdapter.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/annotation/AnnotationMethodHandlerAdapter.java index e6c22dd7aa5..d0916c2aaa2 100644 --- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/annotation/AnnotationMethodHandlerAdapter.java +++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/annotation/AnnotationMethodHandlerAdapter.java @@ -599,9 +599,9 @@ public class AnnotationMethodHandlerAdapter extends WebContentGenerator if (oldMappedMethod != null) { throw new IllegalStateException( "Ambiguous handler methods mapped for HTTP path '" + lookupPath + "': {" + - oldMappedMethod + ", " + handlerMethod + - "}. If you intend to handle the same path in multiple methods, then factor " + - "them out into a dedicated handler class with that path mapped at the type level!"); + oldMappedMethod + ", " + handlerMethod + + "}. If you intend to handle the same path in multiple methods, then factor " + + "them out into a dedicated handler class with that path mapped at the type level!"); } } } @@ -1093,6 +1093,7 @@ public class AnnotationMethodHandlerAdapter extends WebContentGenerator } } + /** * Subclass of {@link RequestMappingInfo} that holds request-specific data. */ @@ -1119,22 +1120,21 @@ public class AnnotationMethodHandlerAdapter extends WebContentGenerator public String bestMatchedPattern() { return (!this.matchedPatterns.isEmpty() ? this.matchedPatterns.get(0) : null); } - } /** - * Comparator capable of sorting {@link RequestSpecificMappingInfo}s (RHIs) so that sorting a list with this comparator will - * result in: + * Comparator capable of sorting {@link RequestSpecificMappingInfo}s (RHIs) so that + * sorting a list with this comparator will result in: *