JDK-8079623 : An AssertionError is raised when parsing JSON
  • Type: Bug
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Affected Version: 8u40
  • Priority: P3
  • Status: Resolved
  • Resolution: Duplicate
  • OS: os_x
  • CPU: x86
  • Submitted: 2015-03-05
  • Updated: 2015-05-28
  • Resolved: 2015-05-28
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
Java(TM) SE Runtime Environment (build 1.8.0_40-b25)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
OS X version 10.9.5

A DESCRIPTION OF THE PROBLEM :
Executing the following code throws an AssertionError:

new NashornScriptEngineFactory().getScriptEngine().eval("JSON.parse(JSON.stringify([{ '1234': 'fun', '4567': 'fun2' }]));");


REGRESSION.  Last worked in version 8u25

ADDITIONAL REGRESSION INFORMATION: 
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run this code:

new NashornScriptEngineFactory().getScriptEngine().eval("JSON.parse(JSON.stringify([{ '1234': 'fun', '4567': 'fun2' }]));");

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No exception thrown.
ACTUAL -
An AssertionError is thrown.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.AssertionError
	at jdk.nashorn.internal.runtime.arrays.DeletedArrayFilter.delete(DeletedArrayFilter.java:150)
	at jdk.nashorn.internal.runtime.arrays.DeletedRangeArrayFilter.delete(DeletedRangeArrayFilter.java:231)
	at jdk.nashorn.internal.runtime.ScriptObject.doesNotHaveEnsureDelete(ScriptObject.java:3125)
	at jdk.nashorn.internal.runtime.ScriptObject.defineOwnProperty(ScriptObject.java:725)
	at jdk.nashorn.internal.runtime.JSONFunctions.setPropertyValue(JSONFunctions.java:200)
	at jdk.nashorn.internal.runtime.JSONFunctions.convertNode(JSONFunctions.java:182)
	at jdk.nashorn.internal.runtime.JSONFunctions.convertNode(JSONFunctions.java:165)
	at jdk.nashorn.internal.runtime.JSONFunctions.parse(JSONFunctions.java:93)
	at jdk.nashorn.internal.objects.NativeJSON.parse(NativeJSON.java:105)
	at jdk.nashorn.internal.scripts.Script$\^eval\_.:program(<eval>:1)
	at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:636)
	at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:229)
	at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:387)
	at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:437)
	at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:401)
	at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:397)
	at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:152)
	at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
new NashornScriptEngineFactory().getScriptEngine().eval("JSON.parse(JSON.stringify([{ '1234': 'fun', '4567': 'fun2' }]));");
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Don't parse JSON with numbers for keys.


Comments
Duplicate of JDK-8068872
28-05-2015

1) Run the attached test case (NashTest.java) in Windows and MAC OS X. 2) Checked this with JDK 8u31, 8u45, 8u60 ea b12, and 9 ea b62: 8u31: OK 8u45: FAIl 8u60 ea b12: OK 9 ea b62: OK 3) Output: JDK 8u45: ------------------------------------------------------------------------------------------------------------------------------------- >java NashTest Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 71 at java.util.Arrays.rangeCheck(Arrays.java:120) at java.util.Arrays.fill(Arrays.java:2868) at jdk.nashorn.internal.runtime.BitVector.setRange(BitVector.java:273) at jdk.nashorn.internal.runtime.arrays.DeletedArrayFilter.delete(DeletedArrayFilter.java:151) at jdk.nashorn.internal.runtime.arrays.DeletedRangeArrayFilter.delete(DeletedRangeArrayFilter at jdk.nashorn.internal.runtime.ScriptObject.doesNotHaveEnsureDelete(ScriptObject.java:3125) at jdk.nashorn.internal.runtime.ScriptObject.defineOwnProperty(ScriptObject.java:725) at jdk.nashorn.internal.runtime.JSONFunctions.setPropertyValue(JSONFunctions.java:200) at jdk.nashorn.internal.runtime.JSONFunctions.convertNode(JSONFunctions.java:182) at jdk.nashorn.internal.runtime.JSONFunctions.convertNode(JSONFunctions.java:165) at jdk.nashorn.internal.runtime.JSONFunctions.parse(JSONFunctions.java:93) at jdk.nashorn.internal.objects.NativeJSON.parse(NativeJSON.java:105) at jdk.nashorn.internal.scripts.Script$\^eval\_.:program(<eval>:1) at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:636) at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:229) at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:387) at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:437) at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:401) at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:397) at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:152) at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264) at NashTest.main(NashTest.java:6) --------------------------------------------------------------------------------------------------------------------------------------- Conclusion: The code run fine with JDK 8u31, 8u60 ea b12, and 9 ea b62, however the current JDK version 8u45 threw an exception error "java.lang.ArrayIndexOutOfBoundsException".
08-05-2015