[jboss-user] [Javassist] - Re: Problem with equals/hashCode?

James Garrison do-not-reply at jboss.com
Thu Jan 20 14:52:48 EST 2011

James Garrison [http://community.jboss.org/people/jgarrison] created the discussion

"Re: Problem with equals/hashCode?"

To view the discussion, visit: http://community.jboss.org/message/582192#582192

Better implementation of getRealDeclaringClass()

        private Class<?> getRealDeclaringClass(Method m) throws NoSuchMethodException
            // Get the method's current declaring class
            Class<?> dcl = m.getDeclaringClass();
            // Special handling for equals and hashCode() -- first unmangle the name
            String name = m.getName().contains("equals") ? "equals" : m.getName().contains("hashCode") ? "hashCode" : null;
            if (name != null)
                // Walk up the class hierarchy to the first non-proxy class
                    dcl = dcl.getSuperclass();
                // Now get the declaring class of the unmangled name
                dcl = dcl.getMethod(name,m.getParameterTypes()).getDeclaringClass();
            return dcl;

Reply to this message by going to Community

Start a new discussion in Javassist at Community

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110120/daec5362/attachment.html 

More information about the jboss-user mailing list