Uploaded image for project: 'Pivot'
  1. Pivot
  2. PIVOT-974

Use of "importClass" or "importPackage" function in Javascript within BXML files won't work under Java 8 Nashorn script engine

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 2.1
    • Fix Version/s: 2.1, 2.0.5
    • Component/s: core-serialization
    • Labels:
      None
    • Environment:
      All

      Description

      A small script such as this in a BXML file now will not work in Java 8:
      <bxml:script>
      importClass(org.apache.pivot.wtk.Button);
      function isSelected(state)

      { return state == Button.State.SELECTED; }

      </bxml:script>
      The reason is that the "importClass" function is not present in the base Nashorn engine, but is provided by a compatibility library: "mozilla_compat.js".

      1. 974.patch
        4 kB
        Roger Whitcomb

        Activity

        Hide
        rwhitcomb Roger Whitcomb added a comment -

        The "974.patch" file implements a fix for this.

        Show
        rwhitcomb Roger Whitcomb added a comment - The "974.patch" file implements a fix for this.
        Hide
        rwhitcomb Roger Whitcomb added a comment -

        Committed this fix in "trunk":
        Sending core\src\org\apache\pivot\beans\BXMLSerializer.java
        Transmitting file data .
        Committed revision 1691618.

        Show
        rwhitcomb Roger Whitcomb added a comment - Committed this fix in "trunk": Sending core\src\org\apache\pivot\beans\BXMLSerializer.java Transmitting file data . Committed revision 1691618.
        Hide
        smartini Sandro Martini added a comment -

        Hi Roger,
        what do you think on backport this fix even in 2.0.x ?

        Show
        smartini Sandro Martini added a comment - Hi Roger, what do you think on backport this fix even in 2.0.x ?
        Hide
        rwhitcomb Roger Whitcomb added a comment -

        I thought about it. At first glance it doesn't seem necessary, but it could be that users will be running on Java 8 even if we build only with Java 6. So, it does probably make sense.

        I can do the merge later today.

        Thanks.

        Show
        rwhitcomb Roger Whitcomb added a comment - I thought about it. At first glance it doesn't seem necessary, but it could be that users will be running on Java 8 even if we build only with Java 6. So, it does probably make sense. I can do the merge later today. Thanks.
        Hide
        smartini Sandro Martini added a comment - - edited

        Yes, it would be great !! Thank you very much.

        Show
        smartini Sandro Martini added a comment - - edited Yes, it would be great !! Thank you very much.
        Hide
        rwhitcomb Roger Whitcomb added a comment -

        Okay, merged to "branches/2.0.x":
        Sending 2.0.x
        Sending 2.0.x/core/src/org/apache/pivot/beans/BXMLSerializer.java
        Transmitting file data .
        Committed revision 1692012.

        Show
        rwhitcomb Roger Whitcomb added a comment - Okay, merged to "branches/2.0.x": Sending 2.0.x Sending 2.0.x/core/src/org/apache/pivot/beans/BXMLSerializer.java Transmitting file data . Committed revision 1692012.
        Hide
        smartini Sandro Martini added a comment -

        Roger, I made some tests even in 2.0.x and all seems to work as before even there (all is ok), is if safe to mark this issue as resolved now or other work is still needed ? Thanks a lot. Bye

        Show
        smartini Sandro Martini added a comment - Roger, I made some tests even in 2.0.x and all seems to work as before even there (all is ok), is if safe to mark this issue as resolved now or other work is still needed ? Thanks a lot. Bye
        Hide
        rwhitcomb Roger Whitcomb added a comment -

        All seems good now.

        Show
        rwhitcomb Roger Whitcomb added a comment - All seems good now.

          People

          • Assignee:
            rwhitcomb Roger Whitcomb
            Reporter:
            rwhitcomb Roger Whitcomb
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development