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

Андрей Завтраков andrey at inlite.ru
Thu Oct 23 14:49:00 UTC 2014


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