commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dmitri Blinov (JIRA)" <>
Subject [jira] [Commented] (JEXL-171) Map access operator does not work if key name clashes with map property name
Date Fri, 31 Jul 2015 06:38:04 GMT


Dmitri Blinov commented on JEXL-171:

Oops, I have just bumped into a problem when accessing a Map property via '.' still returns
a property of the object implementing a Map and not a key-value from Map. I'm using custom
Uberspect implementation which overrides the default one with the follwing code:

   protected final List<ResolverType> resolvingOrder = Arrays.asList(

   public JexlPropertyGet getPropertyGet(Object obj, Object identifier) {
       return getPropertyGet(resolvingOrder, obj, identifier);

   public JexlPropertySet getPropertySet(final Object obj, final Object identifier, final
Object arg) {
       return getPropertySet(resolvingOrder, obj, identifier, arg);

but that code just seems not to be used. After peeping into I have found that
indeed the strategy for accessing methods is not taken from Uberspect but is constructed on
the fly:
        List<JexlUberspect.ResolverType> strategy = (node == null) || !(node.jjtGetParent()instanceof
ASTArrayAccess) ? JexlUberspect.POJO : JexlUberspect.MAP;
        JexlPropertyGet vg = uberspect.getPropertyGet(strategy, object, attribute);

I think it's a bad idea to break a rule of thumb that *a.b* should be equal to *a\["b"\]*.
If one wants to change the order for property resolution globally the custom Uberspect implementation
is right and sufficient way to do so, and combined with annotations for particular objects
we can provide virtually any desired flexibility

> Map access operator does not work if key name clashes with map property name
> ----------------------------------------------------------------------------
>                 Key: JEXL-171
>                 URL:
>             Project: Commons JEXL
>          Issue Type: Bug
>    Affects Versions: 3.0
>            Reporter: Dmitri Blinov
>            Assignee: Henri Biestro
>            Priority: Critical
>             Fix For: 3.0
> The following example returns *false*, according to documentation should return *2*.
> i = new ("java.util.HashMap"); i.a = 1; i["empty"] = 2; i["empty"] 

This message was sent by Atlassian JIRA

View raw message