Archie Cobbs wrote:
Olivier Jolly wrote:
  I bumped into a major problem with spring and easymock which boiled
down to being a subtle definition of a Proxy. In the case of the
creation of a proxy which defines the same method as Object (which is
non final and public), the method in the interface must be so that
getDeclaringClass is Object.class and not the actual interface.

Just curious.. are you sure this is a Classpath issue and not
a VM issue?
yes, as far as the VM isn't handling natively the creation of java.lang.reflect.Proxy. In the Proxy.java source file of classpath we're (incorrectly) building the proxy with methods that shouldn't be there.
What does the failure look like?
Within an InvocationHandler, the method instance which is given as parameter is not equals to Object.class.getDeclaredMethod("...", ...) if the interface the proxy is built on redefines one of the "core" Object methods. Easymock is correctly expecting to catch all "equals" call with Object.class.getDeclaredMethod("equals", new Class[] {Object.class}).equals(method) which is not the case without my patch.
Also (very minor) would isCoreObjectMethod() be more simply implemented
using Object.class.getDeclaringMethod().. ?
Not at all, because the equality you would then use will prevent the checked method (defined in an interface) from matching anything declared in Object.class (because of the getDeclaringClass() difference).

Thanks for the feedback
-Archie
Olivier

Reply via email to