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

JEXL method lookup incorrectly interprets object array param as varargs

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Cannot Reproduce
    • 2.1.1
    • 3.0
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: