Github user aleksandr-m commented on the issue:

    https://github.com/apache/struts/pull/133
  
    Maybe I'm doing something wrong but in my app `method.getDeclaringClass()` 
returns proxied class as well. :(
    
    We can use something like below. Basically same thing that `AopUtil` is 
doing but w/o spring classes.
    
    ```
    private Class<?> getTarget(Object candidate) {
        Class<?> result = null;
        try {
            Method method = candidate.getClass().getMethod("getTargetClass");
            Object obj = method.invoke(candidate);
            if (result instanceof Class) {
                result = (Class<?>) obj;
            }
        } catch (Exception e) {
        }
        if (result == null) {
            if (candidate.getClass().getName().contains("$$")) {
                result = candidate.getClass().getSuperclass();
            } else {
                result = candidate.getClass();
            }
        }
        return result;
    }
    ```
    And to replace `instanceof`.
    
    ```
    private boolean implementsInterfeace(Class<?> clazz, final String 
interfaceName) {
        List<Class<?>> list = 
org.apache.commons.lang3.ClassUtils.getAllInterfaces(clazz);
        if (list != null) {
            for (Class<?> cl : list) {
                if (interfaceName.equals(cl.getName())) {
                    return true;
                }
            }
        }
        return false;
    }
    ```


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to