Nashorn bug in Java 8 u40: Cannot parse JSON: { 0: null, 100: null }
Kaj Magnus Lindberg
kajmagnus79 at gmail.com
Sun Mar 8 05:20:34 UTC 2015
Hi dear Nashorn developers,
There's an ArrayIndexOutOfBoundsException bug when I try to parse this
JSON: '{ "0":null, "100": null }'.
Have a look here:
jjs> JSON.parse('{ "0":null, "65503": null }')
java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 65503
jjs>
jjs> JSON.parse('{ "0":null, "100": null }')
java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 100
jjs>
jjs> JSON.parse('{ "0":null, "65": null }')
java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 65
jjs>
jjs> JSON.parse('{ "0":null, "64": null }') // Works
[object Object]
jjs>
jjs> JSON.parse('{ "_0":null, "_100": null }') // Works
[object Object]
jjs>
jjs>
I found a bug report that was fixed that made { 0: null, 64: null } work.
But as you can see above, { 0: null, 65: null } doesn't work.
https://bugs.openjdk.java.net/browse/JDK-8048718
Version details:
$ java -version
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b25)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)
$ uname -a
Linux kajmagnus-lt-15 3.19.0-031900-generic #201502091451 SMP Mon Feb 9
14:52:52 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/issue
Linux Mint 17.1 Rebecca \n \l
(This bug wasn't present in an earlier Nashorn version, u20 or u22 or
something like that.)
Best regards,
KajMagnus
More information about the nashorn-dev
mailing list