JDK-8189694 : Remove deprecated HostServices::getWebContext method
  • Type: CSR
  • Component: javafx
  • Sub-Component: application-lifecycle
  • Priority: P2
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 10
  • Submitted: 2017-10-19
  • Updated: 2017-10-30
  • Resolved: 2017-10-27
Related Reports
CSR :  
Description
Summary
-------

The JavaFX HostServices::getWebContext method was marked as deprecated for removal in JDK 9 by JDK-8156963. We now propose to remove this method.

Problem
-------

The HostServices::getWebContext method returns an instance of a JSObject that is used for JavaScript <--> Java communication when the application is running in a browser (otherwise it returns null) via the Java plug-in. The Java plug-in is deprecated in JDK 9 with the stated intention of removing it in a future release. Note also that Applets are deprecated as of JDK 9.

Solution
--------

The proposed solution is to simply remove the method in question, along with the API documentation that refers to it.

Specification
-------------

    diff --git a/modules/javafx.graphics/src/main/java/javafx/application/HostServices.java b/modules/javafx.graphics/src/main/java/javafx/application/HostServices.java
    --- a/modules/javafx.graphics/src/main/java/javafx/application/HostServices.java
    +++ b/modules/javafx.graphics/src/main/java/javafx/application/HostServices.java
    @@ -27,16 +27,13 @@
     
     /**
      * This class provides HostServices for an Application. This includes
      * methods to get the code base and document base for an Application,
    - * show a web page in a browser, and communicate with the enclosing web page
    - * using JavaScript if the Application is running in
    - * a browser.
    + * and to show a web page in a browser.
    + *
      * @since JavaFX 2.0
      */
     public final class HostServices {
    @@ -125,34 +122,4 @@
             delegate.showDocument(uri);
         }
     
    -    /**
    -     * Returns the JavaScript handle of the enclosing DOM window of the web
    -     * page containing this application.
    -     * This handle is used to access the web page by calling from Java into
    -     * JavaScript.
    -     * If the application is not embedded into a web page, this method
    -     * return null.
    -     *
    -     * <p>Example:</p>
    -     * <pre>{@code
    -     *     JSObject jsWin = getHostServices().getWebContext();
    -     *     if (jsWin != null) {
    -     *         jsWin.eval("var b = document.body;" +
    -     *                    "var newdiv = document.createElement('div');" +
    -     *                    "newdiv.innerHTML = '<br>Hello from JavaScript!';" +
    -     *                    "b.appendChild(newdiv);");
    -     *     }
    -     * }</pre>
    -     *
    -     * @return handle of the enclosing DOM window of the web page containing
    -     * this application
    -     *
    -     * @deprecated This method is deprecated as of JDK 9 because the
    -     * {@link java.applet.Applet Applet} API is deprecated.
    -     */
    -    @Deprecated(since="9", forRemoval=true)
    -    public final JSObject getWebContext() {
    -        ...
    -    }
    -
     }


Comments
Moving to approved.
27-10-2017

Moving to provisional; please finalize the request so it can go through the second round of review to be approved.
27-10-2017