struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yasserzamani <...@git.apache.org>
Subject [GitHub] struts pull request #124: WW-4744: AnnotationUtils supports non-public metho...
Date Tue, 21 Mar 2017 09:44:09 GMT
Github user yasserzamani commented on a diff in the pull request:

    https://github.com/apache/struts/pull/124#discussion_r107110525
  
    --- Diff: core/src/main/java/com/opensymphony/xwork2/util/AnnotationUtils.java ---
    @@ -150,25 +166,32 @@ public static void addAllInterfaces(Class clazz, List<Class>
allInterfaces) {
          * @return the annotation found, or {@code null} if none
          */
         public static <A extends Annotation> A findAnnotation(Method method, Class<A>
annotationType) {
    -        A result = getAnnotation(method, annotationType);
    -        Class<?> clazz = method.getDeclaringClass();
    +        AnnotationCacheKey cacheKey = new AnnotationCacheKey(method, annotationType);
    +        A result = (A) findAnnotationCache.get(cacheKey);
             if (result == null) {
    -            result = searchOnInterfaces(method, annotationType, clazz.getInterfaces());
    -        }
    -        while (result == null) {
    -            clazz = clazz.getSuperclass();
    -            if (clazz == null || clazz.equals(Object.class)) {
    -                break;
    -            }
    -            try {
    -                Method equivalentMethod = clazz.getDeclaredMethod(method.getName(), method.getParameterTypes());
    -                result = getAnnotation(equivalentMethod, annotationType);
    -            } catch (NoSuchMethodException ex) {
    -                // No equivalent method found
    -            }
    +            result = getAnnotation(method, annotationType);
    +            Class<?> clazz = method.getDeclaringClass();
                 if (result == null) {
                     result = searchOnInterfaces(method, annotationType, clazz.getInterfaces());
                 }
    +            while (result == null) {
    +                clazz = clazz.getSuperclass();
    +                if (clazz == null || clazz.equals(Object.class)) {
    +                    break;
    +                }
    +                try {
    +                    Method equivalentMethod = clazz.getDeclaredMethod(method.getName(),
method.getParameterTypes());
    +                    result = getAnnotation(equivalentMethod, annotationType);
    +                } catch (NoSuchMethodException ex) {
    +                    // No equivalent method found
    --- End diff --
    
    No, it is common to not found the method in one of supercleasses during our hierarchically
search.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Mime
View raw message