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

ClassCastException when using Nashorn engine with multiple bindings

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • None
    • core-libs
    • None
    • generic
    • generic

      From http://stackoverflow.com/questions/35563250/attempting-to-make-nashorn-thread-safe

      When using a Nashorn engine with multiple bindings some JavaScript methods throw a java.lang.ClassCastException when turning megamorphic. It seems that megamorphic access does not work with specialized LinkLogic introduced in 8u40. The attached Test class can be used to reproduce this. It generates the exception below.

      Exception in thread "main" java.lang.ClassCastException: jdk.nashorn.internal.objects.NativeRegExpExecResult cannot be cast to jdk.nashorn.internal.objects.NativeArray
      at jdk.nashorn.internal.objects.NativeArray.getContinuousArrayDataCCE(NativeArray.java:1898)
      at jdk.nashorn.internal.objects.NativeArray.popObject(NativeArray.java:945)
      at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:656)
      at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:229)
      at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:387)
      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 Test.executeMethod(Test.java:21)
      at Test.main(Test.java:14)

            hannesw Hannes Wallnoefer
            hannesw Hannes Wallnoefer
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: