Objects with more than 256 keys cause all associated values to become undefined

Mark Elliot mark.elliot at gmail.com
Mon May 4 03:47:54 UTC 2015


I ran across this while trying to get the TypeScript compiler to run
natively on Nashorn. The compiler includes a large mapping of keys to
diagnostic descriptions in ts.Diagnostics.

After bumping from 1.8.0_05 to 1.8.0_45, the values in the ts.Diagnostics
map became undefied. I've boiled the issue down to a simple repro, and it
appears that objects of the form:

var foo = {
    field_1: { code: 1 },
    field_2: { code: 2 },
    ...
    field_256: { code: 256 },
    field_257: { code: 257 }
}

Cause all values associated with keys to become undefined, even though the
keys themselves exist. That is, attempting to access any value, e.g.
foo.field_1, will return undefined, instead of the expected object.

The problem appears to occur when more than 256 keys are specified, as
running these two gists through jjs would easily show:
256 keys: https://gist.github.com/markelliot/359810cdd27c90f0e13d
257 keys: https://gist.github.com/markelliot/cf6268b0627b54921583

Notably, I don't observe the issue when the values are not objects, so this
object would behave as one would expect:

var bar = {
    field_1: 1,
    field_2: 2,
    ...
    field_256: 256,
    field_257: 257
}


More information about the nashorn-dev mailing list