3 Replies Latest reply: Feb 11, 2013 8:15 PM by shakir.gusaroff RSS

    JavaFX 8 and new Java 8 libraries

    James_D
      JavaFX 2 was clearly designed with an eye on new features coming in Java 8, particularly lamba expressions. As a result, there are some JavaFX APIs which have anticipated Java 8 library enhancements. For example, the javafx.util.Callback interface is basically identical to the proposed java.util.function.Function interface (see [url http://cr.openjdk.java.net/~briangoetz/lambda/sotc3.html]here or [url http://sett.ociweb.com/sett/settFeb2013.html]here).

      Are there plans to retrofit JavaFX APIs to support the new Java 8 libraries (so I can pass a Function instead of a Callback to a setCellFactory(...) method)? It would seem to make sense to unify around the new Java APIs rather than having JavaFX versions of them. Should we expect Callback to eventually be deprecated in favor of Function?
        • 1. Re: JavaFX 8 and new Java 8 libraries
          866711
          This would be an API breaking change and I don't see a reason for it. People using lambda expression won't care if one passes a Callback or Function because the compiler does generate the appropriate bytecode representing the SAM type.
          • 2. Re: JavaFX 8 and new Java 8 libraries
            James_D
            I guess I was envisioning scenarios where a (FX agnostic) business layer exposed Functions for manipulating data in the model. But I suppose "converting" these to Callbacks becomes completely trivial using function references... I was still thinking with my Java 7 hat on.

            It still seems a bit unwieldy to have different core APIs replicating identical functionality, though.
            • 3. Re: JavaFX 8 and new Java 8 libraries
              shakir.gusaroff
              It still seems a bit unwieldy to have different core APIs replicating identical functionality, though.
              Java 8 will include a Java Time API which will contain classes such as:
              java.time.Duration and java.time.Period.
              JavaFX also contains javafx.util.Duration