Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: 1.1-beta-1, 1.1-beta-2
-
Fix Version/s: 1.1-rc-2
-
Component/s: None
-
Labels:None
-
Testcase included:yes
-
Patch Submitted:Yes
-
Number of attachments :
Description
Groovy beans wrapped in JDK style proxies throw an "IllegalArgumentException: object is not an instance of declaring class" when a method is called on them from a Groovy object.
Thread on subject from the dev list: http://www.nabble.com/JDK-Style-Proxy-Issue-tf4137792.html
Diagnosis from Jochen Theodorou: http://www.nabble.com/Re%3A-JDK-Style-Proxy-Issue-p11815320.html
This is a patch from groovy-core/src.
This patch includes all of the test cases from the previous patch and a fix for the issue.
I have added an interfaceMetaMethod property to MetaMethod. This allows MetaMethod to know if the method it is invoking was declared on an interface. Then the logic to invoke the method checks to see if the type of MetaMethod.method implementing class == the type of the target object. If it does not and there is an interfaceMetaMethod it delegates the invocation to the interfaceMetaMethod.
In MetaClass I've added a new method that wires a newly create MetaMethod to its implementing MetaMethod if one exists. This is called from createMetaMethod().
All existing tests in the current trunk pass with this patch applied.