Nashorn: error getting object property using string concatenation as a key

Jim Laskey (Oracle) james.laskey at oracle.com
Thu Oct 23 15:11:39 UTC 2014


Filed as https://bugs.openjdk.java.net/browse/JI-9016029

On Oct 23, 2014, at 11:49 AM, Андрей Завтраков <andrey at inlite.ru> wrote:

> given a simple AbstractJSObject binded as 'vars' to the script execution
> context:
> 
> public class VarsAdapter extends AbstractJSObject
> {
> 
>    @Override
>    public Object getMember(String name)
>    {
>        return name;
>    }
> }
> 
> Javascript source:
> 
> o = 6;
> print( '1: '+vars['price_'+o]);
> print( '2: '+vars['price_6']);
> print( '3: '+vars[('price_'+o).toString()]);
> 
> result is:
> 
> 1: null
> 2: price_6
> 3: price_6
> 
> in case 1 getMember() is not called. This looks like a bug,



More information about the nashorn-dev mailing list