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
while(dcl.getName().contains("javassist"))
dcl = dcl.getSuperclass();
// Now get the declaring class of the unmangled name
dcl = dcl.getMethod(name,m.getParameterTypes()).getDeclaringClass();
}
return dcl;
}