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

JavaAdapters do not work with ScriptObjectMirror objects

    XMLWordPrintable

Details

    Description

      Found one issue in stackoverflow http://stackoverflow.com/questions/37611959/java-8-passing-a-function-through-bindings
      JS function declared in the engine scope. Invoking withoutProxy works fine. But withProxy throws java.lang.ClassCastException:
      ==
      -sh-4.1$ /opt/java/jdk1.8.0_102/bin/java Foo
      1.8.0_102
      Exception in thread "main" java.lang.ClassCastException: Cannot cast jdk.nashorn.api.scripting.ScriptObjectMirror to java.util.function.Function
              at java.lang.invoke.MethodHandleImpl.newClassCastException(MethodHandleImpl.java:361)
              at java.lang.invoke.MethodHandleImpl.castReference(MethodHandleImpl.java:356)
              at jdk.nashorn.internal.scripts.Script$Recompilation$5$17A$\^eval\_.proxy(<eval>:1)
              at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:639)
              at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
              at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
              at jdk.nashorn.api.scripting.ScriptObjectMirror.call(ScriptObjectMirror.java:117)
              at jdk.nashorn.internal.scripts.Script$Recompilation$4$20$\^eval\_.withProxy(<eval>:1)
              at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:637)
              at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
              at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
              at jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:199)
              at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:383)
              at jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction(NashornScriptEngine.java:190)
              at Foo.main(Foo.java:22)

      Attachments

        Issue Links

          Activity

            People

              hannesw Hannes Wallnoefer
              fmatte Fairoz Matte (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: