Uploaded image for project: 'Commons JEXL'
  1. Commons JEXL
  2. JEXL-154

JEXL method lookup incorrectly interprets object array param as varargs

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Cannot Reproduce
    • Affects Version/s: 2.1.1
    • Fix Version/s: 3.0
    • Labels:
      None

      Description

      Say I have an object in my context with a method like:

      public <T> List<T> asList(T[] array) {
          return Arrays.asList(array);
      }
      

      When I call that from a JEXL expression with something like:

      utils.asList(["foo", "bar"])
      

      The JEXL method finder seems to treat the method like a varargs method, and puts the whole string array into the first element of the formal parameter, rather than mapping the string array onto the object array. That is, the method receives an array of length 1, with that first element being a string array of length 2.

      To illustrate further, the problem goes away if I change the method to look like:

      public <T> List<T> asList(T[] array, String ... dummy) {
          return Arrays.asList(array);
      }
      

      since this forces the T[] array to be interpreted correctly.

        Attachments

          Activity

            People

            • Assignee:
              henrib Henri Biestro
              Reporter:
              davidloone David Loone
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: