object with numeric indexes fills up
A. Sundararajan
sundararajan.athijegannathan at oracle.com
Wed Oct 29 13:24:50 UTC 2014
This is fixed in jdk8u40 and jdk9. You can download 8u40 early access
binary from https://jdk8.java.net/download.html
regards,
-Sundar
On Wednesday 29 October 2014 05:48 PM, Christoph Gritschenberger wrote:
> I ran into an oddity when listing the keys of an object today.
> If I add a value with a numeric key >=524288 and then add more than one
> value with a key <524288, nashorn fills up the space between the lower
> indexes.
>
> I got some sample-code here:
>
> ScriptEngine engine = new
> ScriptEngineManager().getEngineByName("javascript");
> Object eval = engine.eval("var x = {}; x[524287] = 'xxx'; x[1] =
> 'foo'; x[3] = 'bar'; Object.keys(x);");
> System.out.println(((Map) eval).values());
> // prints [1, 3, 524287] as expected
> eval = engine.eval("var x = {}; x[524288] = 'xxx'; x[1] = 'foo';
> x[3] = 'bar'; Object.keys(x);");
> System.out.println(((Map) eval).values());
> // prints [1, 2, 3, 524288]
>
> Any idea why that is?
>
> kind regards,
> Christoph
>
>
More information about the nashorn-dev
mailing list