You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "David Loone (JIRA)" <ji...@apache.org> on 2015/05/26 14:30:17 UTC

[jira] [Created] (JEXL-154) JEXL method lookup incorrectly interprets object array param as varargs

David Loone created JEXL-154:
--------------------------------

             Summary: JEXL method lookup incorrectly interprets object array param as varargs
                 Key: JEXL-154
                 URL: https://issues.apache.org/jira/browse/JEXL-154
             Project: Commons JEXL
          Issue Type: Bug
    Affects Versions: 2.1.1
            Reporter: David Loone
            Priority: Minor


Say I have an object in my context with a method like:
{code}
public <T> List<T> asList(T[] array) {
    return Arrays.asList(array);
}
{code}

When I call that from a JEXL expression with something like:
{code}
utils.asList(["foo", "bar"])
{code}

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:
{code}
public <T> List<T> asList(T[] array, String ... dummy) {
    return Arrays.asList(array);
}
{code}
since this forces the T[] array to be interpreted correctly.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)