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

MetaObjectProtocol.getMetaMethod doc for "args" is ambiguous

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • 1.8.4
    • 1.8.5, 2.0-beta-2
    • None
    • None

    Description

      http://groovy.codehaus.org/api/groovy/lang/MetaObjectProtocol.html#getMetaMethod(java.lang.String, java.lang.Object[])

      The args parameter is described as "The argument types", but the method definition says "Retrieves an instance MetaMethod for the given name and argument values, using the types of the argument values to establish the chosen MetaMethod".

      For the former, I'd expect to pass in something like [String.class]; from the latter I'd expect to have to pass in [""]


      The code actually works with both!
      Looks like it eventually calls MetaClassHelper.castArgumentsToClassArray, which uses the arg if it's a Class, or uses argType.getClass() otherwise.

      If this is guaranteed to be the case in future version, then I'd suggest the wording:
      @param args The argument types: can be the Class objects, or example argument values for inferring the types

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            roshandawrani Roshan Dawrani
            aled.sage@gmail.com Aled Sage
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment