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

Nashorn FX example 3-4 using load for fx: scripts fails to run with latest jdk9 ea build

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 9
    • 9
    • core-libs
    • b153
    • generic
    • generic

      This issue was reported by Carl Dea by via twitter ( https://twitter.com/carldea/status/818670889361375232 )

      File: x.js
      -----------

      load("fx:base.js");
      load("fx:controls.js");
      load("fx:graphics.js");

      $STAGE.title = "Hello World!";
      var button = new Button();
      button.text = "Say 'Hello World'";
      button.onAction = function() print("Hello World!");
      var root = new StackPane();
      root.children.add(button);
      $STAGE.scene = new Scene(root, 300, 250);
      $STAGE.show();

      The above script was copied from section 3-4 ("Example 3-4 JavaFX Script Application with Loaded Scripts") of https://docs.oracle.com/javase/8/docs/technotes/guides/scripting/nashorn/javafx.html

      Stack trace looks as follows:

      Exception in Application start method
      Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
      at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown Source)
      at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(Unknown Source)
      at java.base/java.lang.Thread.run(Unknown Source)
      Caused by: java.lang.ClassCastException: Cannot cast jdk.nashorn.internal.runtime.Undefined to java.nio.file.Path
      at java.base/java.lang.Class.cast(Unknown Source)
      at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$22$809$\=fx\!base$cu1$restOf.L:50(fx:base.js:111)
      at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$10$\=fx\!base.:program(fx:base.js:50)
      at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(Unknown Source)
      at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunction.invoke(Unknown Source)
      at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptRuntime.apply(Unknown Source)
      at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.Context.evaluateSource(Unknown Source)
      at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.Context.load(Unknown Source)
      at jdk.scripting.nashorn/jdk.nashorn.internal.objects.Global.load(Unknown Source)
      at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$8$x/520611190.:program(/Users/SATHIJEG/x.js:1)
      at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(Unknown Source)
      at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunction.invoke(Unknown Source)
      at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptRuntime.apply(Unknown Source)
      at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.Context.evaluateSource(Unknown Source)
      at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.Context.load(Unknown Source)
      at jdk.scripting.nashorn/jdk.nashorn.internal.objects.Global.load(Unknown Source)
      at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$6$839A$\=fx\!bootstrap$cu1$restOf.start(fx:bootstrap.js:47)
      at jdk.nashorn.javaadapters.javafx_application_Application.start(Unknown Source)
      at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(Unknown Source)
      at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$11(Unknown Source)
      at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$9(Unknown Source)
      at java.base/java.security.AccessController.doPrivileged(Native Method)
      at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Unknown Source)
      at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)

            sundar Sundararajan Athijegannathan
            sundar Sundararajan Athijegannathan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: