# HG changeset patch # User kcr # Date 1508452567 25200 # Thu Oct 19 15:36:07 2017 -0700 # Node ID 07c5cb2981cd80c4afb57030b365753e3a4ebd92 # Parent 8c150dbef9c51ca32ee5aa93b5cfdc2c8c7f200b 8187149: Remove HostServices::getWebContext Reviewed-by: diff --git a/apps/toys/Hello/src/main/java/hello/HelloHostServices.java b/apps/toys/Hello/src/main/java/hello/HelloHostServices.java --- a/apps/toys/Hello/src/main/java/hello/HelloHostServices.java +++ b/apps/toys/Hello/src/main/java/hello/HelloHostServices.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,6 @@ final HostServices hs = getHostServices(); final Label codeBaseText = new Label(); final Label documentBaseText = new Label(); - final Label webContextText = new Label(); final Label showDocumentText = new Label(); stage.setTitle("Hello HostServices"); @@ -67,24 +66,18 @@ Button getDocumentBaseBtn = new Button("Get DocumentBase"); getDocumentBaseBtn.setOnAction(event -> documentBaseText.setText(hs.getDocumentBase())); - // getWebContext() in HostServices has been deprecated and marked for removal - Button getWebContextBtn = new Button("Get WebContext"); - getWebContextBtn.setOnAction(event -> webContextText.setText( - (hs.getWebContext() != null) ? hs.getWebContext().toString() : "NULL")); - Button showDocmentBtn = new Button("Show Document"); showDocmentBtn.setOnAction(event -> showDocument(hs, showDocumentText, "http://www.oracle.com/java/")); VBox textBox = new VBox(15); textBox.setFillWidth(false); - textBox.getChildren().addAll(codeBaseText, documentBaseText, webContextText, showDocumentText); + textBox.getChildren().addAll(codeBaseText, documentBaseText, showDocumentText); VBox buttonBox = new VBox(5); buttonBox.getChildren().addAll( getCodeBaseBtn, getDocumentBaseBtn, - getWebContextBtn, showDocmentBtn); HBox root = new HBox(7); diff --git a/modules/javafx.graphics/src/main/java/com/sun/javafx/application/HostServicesDelegate.java b/modules/javafx.graphics/src/main/java/com/sun/javafx/application/HostServicesDelegate.java --- a/modules/javafx.graphics/src/main/java/com/sun/javafx/application/HostServicesDelegate.java +++ b/modules/javafx.graphics/src/main/java/com/sun/javafx/application/HostServicesDelegate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,8 +33,6 @@ import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import javafx.application.Application; -import netscape.javascript.JSObject; - public abstract class HostServicesDelegate { @@ -84,8 +82,6 @@ public abstract void showDocument(String uri); - public abstract JSObject getWebContext(); - // StandaloneHostService implementation private static class StandaloneHostService extends HostServicesDelegate { @@ -193,9 +189,5 @@ e.printStackTrace(); } } - - @Override public JSObject getWebContext() { - return null; - } } } 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 @@ import java.net.URI; -import netscape.javascript.JSObject; - import com.sun.javafx.application.HostServicesDelegate; /** * 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. - * - *
Example:
- *{@code - * JSObject jsWin = getHostServices().getWebContext(); - * if (jsWin != null) { - * jsWin.eval("var b = document.body;" + - * "var newdiv = document.createElement('div');" + - * "newdiv.innerHTML = '- * - * @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() { - return delegate.getWebContext(); - } - } diff --git a/modules/javafx.graphics/src/main/java/module-info.java b/modules/javafx.graphics/src/main/java/module-info.java --- a/modules/javafx.graphics/src/main/java/module-info.java +++ b/modules/javafx.graphics/src/main/java/module-info.java @@ -36,7 +36,6 @@ module javafx.graphics { requires java.desktop; requires java.xml; - requires jdk.jsobject; requires transitive javafx.base; diff --git a/tests/system/src/test/java/test/com/sun/javafx/application/HostServicesTest.java b/tests/system/src/test/java/test/com/sun/javafx/application/HostServicesTest.java --- a/tests/system/src/test/java/test/com/sun/javafx/application/HostServicesTest.java +++ b/tests/system/src/test/java/test/com/sun/javafx/application/HostServicesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ package test.com.sun.javafx.application; -import com.sun.javafx.PlatformUtil; +import java.lang.reflect.Method; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import javafx.application.Application; @@ -113,6 +113,13 @@ public void testWebContext() { final HostServices hs = myApp.getHostServices(); assertNotNull(hs); - assertNull(hs.getWebContext()); + + boolean nsme = false; + try { + Method m_getWebContext = HostServices.class.getMethod("getWebContext"); + } catch (NoSuchMethodException ex) { + nsme = true; + } + assertTrue("Did not get the expected NoSuchMethodException", nsme); } }
Hello from JavaScript!';" + - * "b.appendChild(newdiv);"); - * } - * }