Nashorn bug in Java 8 u40: Cannot parse JSON: { 0: null, 100: null }

Hannes Wallnoefer hannes.wallnoefer at oracle.com
Mon Mar 9 10:28:18 UTC 2015


Hi Kaj Magnus,

Thanks for the report. It's unfortunate this bug ended up in 8u40. 
Obviously the fix for the bug you linked was incomplete, and we weren't 
aware of that.

The problem has been fixed in the meantime (together with a rewrite of 
the JSON parser that makes JSON parsing much faster). The fix will be 
part of the 8u60 release. The current 8u60 early access release 
available at https://jdk8.java.net/download.html already contains the fix.

I'm also adding additional tests so this won't happen again:

https://bugs.openjdk.java.net/browse/JDK-8074687

Regards,
Hannes

Am 2015-03-08 um 06:20 schrieb Kaj Magnus Lindberg:
> 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