Uploaded image for project: 'XWiki Commons'
  1. XWiki Commons
  2. XCOMMONS-2158

Improve strategy for selecting a method from velocity

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 12.10.4
    • Fix Version/s: 13.7-rc-1
    • Component/s: Velocity
    • Labels:
      None
    • Difficulty:
      Unknown
    • Similar issues:

      Description

      When we are calling a Java method from a Velocity script, if no method can be found with the right name and the exact right argument types we are iterating over the method names with the right number of arguments and we are trying to perform argument type conversion to match a method.
      This is useful since we have type converter, but this strategy might actually have random results since several methods can be matching and the sorting of velocity methods is random.
      So for example, if I have methods getFoo(String, TypeA) and getFoo(String, String), and the converter TypeA <-> String, calling getFoo with two arguments of type TypeA can lead to one method call or the other.

      IMO it would make sense that in that specific case, the first method (getFoo(String, TypeA)) is called, since one of the argument type is an exact match. So I think we should improve this strategy to count the actual number of arguments that needs a conversion for deciding which method to chose.

        Attachments

          Activity

            People

            Assignee:
            tmortagne Thomas Mortagne
            Reporter:
            surli Simon Urli
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Date of First Response: