Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8079145

jdk.nashorn.internal.runtime.arrays.IntArrayData.convert assertion

    XMLWordPrintable

    Details

      Backports

        Description

        Nashorn can show an assertion failure when converting arrays of floats.
        This worked in 1.8.0_31, fails in 1.8.0_40, 1.8.0_45.

        function floatTest() {
            var jsArray = [35250.123456789];
            var jFloat = Java.to(jsArray, "float[]");
            print(j2jsarray(jFloat));
        }

        function j2jsarray(jArray) {
            var out = new Array();
            // out[0]=1.2; this will avoid the assertion failure.
            for (var i = 0; i < jArray.length; i++) {
                out[i] = jArray[i];
            }
            return out;
        }

        floatTest();


        Exception in thread "main" java.lang.AssertionError
        at
        jdk.nashorn.internal.runtime.arrays.IntArrayData.convert(IntArrayData.java:191
        )
        at
        jdk.nashorn.internal.runtime.arrays.IntArrayData.set(IntArrayData.java:241)
        at
        jdk.nashorn.internal.runtime.ScriptObject.doesNotHave(ScriptObject.java:3166)
        at jdk.nashorn.internal.runtime.ScriptObject.set(ScriptObject.java:3384)
        at
        jdk.nashorn.internal.scripts.Script$Recompilation$2$167A$\^eval\_.j2jsarray(<e
        val>:12)
        at
        jdk.nashorn.internal.scripts.Script$Recompilation$1$22$\^eval\_.floatTest(<eva
        l>:5)
        at jdk.nashorn.internal.scripts.Script$\^eval\_.:program(<eval>:17)
        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.jav
        a:437)
        at
        jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.jav
        a:401)
        at
        jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.jav
        a:397)
        at
        jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:14
        7)
        at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:249)
        at FloatTestApp.main(FloatTestApp.java:13)

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                sundar Sundararajan Athijegannathan
                Reporter:
                shadowbug Shadow Bug
                Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: