[
https://issues.apache.org/jira/browse/JEXL-298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16839228#comment-16839228
]
Dmitri Blinov edited comment on JEXL-298 at 5/16/19 9:45 AM:
-------------------------------------------------------------
BTW, I have checked that documentation does not mention the {{empty}} and
{{size}} as keywords, so one can expect that its perfectly OK to use them as
property names or method identifiers. As a side note to this task - I also have
noticed that in current implementation the parametersless {{empty()}} and
{{size()}} methods are actually not calling the corresponding object methods,
they are delegating their calls to operators {{empty()}} and {{size()}}, so
that now the
{code:java}
x.empty(){code}
is equivalent to
{code:java}
empty(x){code}
. Operators {{empty()}} and {{size()}} may be overloaded, and behave
differently to the object methods, and I think this is bad idea to have them
mixed. If one writes {{x.empty()}} this means one wants to call object method,
not an overloaded operator, at least in the first place.For example, now the
code
{code:java}
x = null; x.empty(){code}
returns {{true}} which is kind of unexpected result. IMO, we have this to be
fixed too.
was (Author: dmitri_blinov):
BTW, I have checked that documentation does not mention the {{empty}} and
{{size}} as keywords, so one can expect that its perfectly OK to use them as
property names or method identifiers. As a side note to this task - I also have
noticed that in current implementation the parametersless {{empty()}} and
{{size()}} methods are actually not calling the corresponding object methods,
they are delegating their calls to operators {{empty()}} and {{size()}}, so
that now the {code}x.empty(){code} is equivalent to {code}empty(x){code}.
Operators {{empty()}} and {{size()}} may be overloaded, and behave differently
to the object methods, and I think this is bad idea to have them mixed. If one
writes {{x.empty()}} this means one wants to call object method, not an
overloaded operator, at least in the first place. IMO, we have this to be fixed
too.
> Unable to call 'empty' and 'size' member methods with parameters
> ----------------------------------------------------------------
>
> Key: JEXL-298
> URL: https://issues.apache.org/jira/browse/JEXL-298
> Project: Commons JEXL
> Issue Type: Improvement
> Affects Versions: 3.1
> Reporter: Dmitri Blinov
> Priority: Major
>
> It's not possible to parse scripts like
> {code:java}
> x.size(0){code}
> or
> {code:java}
> x.empty(0){code}
> because of current syntax restrictions.
> {{empty}} and {{size}} are perfectly valid method identifiers in java, and
> though uncommon, can be declared with arguments. As of now Jexl allows only
> to call parameterless {{empty()}} and {{size()}} methods
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)