Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-8408

invokeMethod cannot be set through category

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.x, 2.5.x, 2.4.13, 2.6.0-alpha-2
    • Component/s: None
    • Labels:
      None

      Description

      In the Groovy in Action book, chapter 8.4.5 says

      Category method names can well take the form of property accessors (pretending property access), operator methods, and GroovyObject methods. MOP hook methods cannot be added through a category class. This is a restriction as of Groovy 2.4. The feature may become available in later versions.

      It interpreted this as meaning that I can add GroovyMethods (getProperty,
      getMetaClass, invokeMethod , setMetaClass and setProperty) to a class using categories but not
      methodMissing or propertyMissing (which I think they call MOP hook methods in the GINA book).

      But when I tried to add invokeMethod using a category the change has no effect, adding missingMethod does not work either see attachement.

      I see that methodsMissing/ propertyMissing via category was probably never supported noted in GROOVY-3867. But the Groovy in Action paragraph makes me think that invokeMethod et al were supported at some point.

      Mailing list thread with Jochen Theodorou on the mailing list

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                daniel_sun Daniel Sun
                Reporter:
                ecerulm Ruben Laguna
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: