Groovy
  1. Groovy
  2. GROOVY-4720

Method overriding with ExpandoMetaClass is partially broken

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.8-rc-4, 1.9-beta-1, 1.7.11
    • Component/s: None
    • Labels:
      None

      Description

      There is a regression whereby you cannot override methods using ExpandoMetaClass.

      The reason is that ClosureMetaMethod.createMethodList creates an anonymous inner class of type MetaMethod and adds it to the returned List<MetaMethod> that are to be registered

      Later the isNonRealMethod(MetaMethod) check in MetaMethodIndex does this check:

          private boolean isNonRealMethod(MetaMethod method) {
              return method instanceof NewInstanceMetaMethod ||
                      method instanceof NewStaticMetaMethod ||
                      method instanceof ClosureMetaMethod ||
                      method instanceof GeneratedMetaMethod ||
                      method instanceof ClosureStaticMetaMethod ||
                      method instanceof MixinInstanceMetaMethod;
          }
      

      Since the anonymous inner MetaMethod defined in ClosureMetaMethod is not an instance of any of these types then the method is never registered in the MetaMethodIndex:

                          if (methodC == matchC) {
                              if (isNonRealMethod(method)) {
                                  list.set(found, method);
                              }
      

        Activity

        Graeme Rocher created issue -
        Guillaume Delcroix made changes -
        Field Original Value New Value
        Attachment GROOVY-4720__Method_overriding_with_ExpandoMetaClass_is_partially_broken.patch [ 54254 ]
        Guillaume Delcroix made changes -
        Fix Version/s 1.8-rc-3 [ 17228 ]
        Fix Version/s 1.8-rc-4 [ 17245 ]
        Guillaume Delcroix made changes -
        Priority Blocker [ 1 ] Critical [ 2 ]
        Guillaume Delcroix made changes -
        Assignee Guillaume Laforge [ guillaume ]
        Guillaume Delcroix made changes -
        Fix Version/s 1.9-beta-1 [ 17153 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Fix Version/s 1.7.11 [ 17244 ]
        Paul King made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
        Mark Thomas made changes -
        Workflow jira [ 12733650 ] Default workflow, editable Closed status [ 12745461 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Workflow jira [ 12973439 ] Default workflow, editable Closed status [ 12980670 ]

          People

          • Assignee:
            Guillaume Delcroix
            Reporter:
            Graeme Rocher
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development