groovy

JDK Dynamic Proxies Broken

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Critical 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 :
    2

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

Activity

Hide
Mark Menard added a comment -

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.

Show
Mark Menard added a comment - 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.
Hide
Mark Menard added a comment -

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.

Show
Mark Menard added a comment - 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.
Hide
Guillaume Laforge added a comment -

Hi Mark,
I had a quick look at this issue, and the Groovy code base has changed a little since.
Do you still encounter the same problem?
If yes, could I ask you to update your patch, please?

Show
Guillaume Laforge added a comment - Hi Mark, I had a quick look at this issue, and the Groovy code base has changed a little since. Do you still encounter the same problem? If yes, could I ask you to update your patch, please?
Hide
Mark Menard added a comment -

Hi Guillaume,

I've tried out the 1.1-beta-3 from http://repo1.maven.org/maven2/groovy/groovy-all/1.1-beta-3/. If that is the released version of 1.1-beta-3 then it has not fixed the issue.

If I have time I will check out the SVN and take a look at this again. (I'm a bit buried on a project right now.) What is the time to the first RC? And does this need to be fixed before then to make it into 1.1?

Mark

Show
Mark Menard added a comment - Hi Guillaume, I've tried out the 1.1-beta-3 from http://repo1.maven.org/maven2/groovy/groovy-all/1.1-beta-3/. If that is the released version of 1.1-beta-3 then it has not fixed the issue. If I have time I will check out the SVN and take a look at this again. (I'm a bit buried on a project right now.) What is the time to the first RC? And does this need to be fixed before then to make it into 1.1? Mark
Hide
Guillaume Laforge added a comment -

We plan to release RC-1 tomorrow evening (ie in 24 hours or so).
And 1.1 mid-November.
As it's a "bug fix" and not a "feature", we can include the fix in after tomorrow if you don't have time to look till tomorrow.

Show
Guillaume Laforge added a comment - We plan to release RC-1 tomorrow evening (ie in 24 hours or so). And 1.1 mid-November. As it's a "bug fix" and not a "feature", we can include the fix in after tomorrow if you don't have time to look till tomorrow.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: