Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

8264139: Suppress removal warnings for Security Manager methods #528

Closed

Conversation

@kevinrushforth
Copy link
Member

@kevinrushforth kevinrushforth commented Jun 3, 2021

This PR adds the necessary @SuppressWarnings("removal") annotations for the recently-integrated security manager deprecation, JEP 411. See openjdk/jdk#4073.

There are four commits:

  1. 678b026 : A patch generated by @wangweij to add annotations to the runtime (modules/*/src/main/java) using the same automated tooling that he used as part of the implementation of JEP 411.
  2. 9698e87 : Same as above for the tests.
  3. 1c42cf8 : Manually removes a pair of unused imports, one of which (a static import) was causing a removal warning.
  4. 4f87d18 : Manually reduced the scope of the annotation where it was added to an entire class, or to a large method where only a small part of the method uses a deprecated method. This was done using similar techniques to the following fixes that Weijun did in openjdk/jdk#4172.

The first two commits represent the bulk of the changes. Other than scanning to ensure that there are no obvious errors, and testing, they probably don't need the same level of scrutiny as the manual changes do.

I tested this on all three platforms by doing a build / test with JDK_HOME set to a local JDK 17 ea build that includes the fix for JEP 411. I ran the build with gradle -PLINT=removal and verified that there were removal warnings for the security manager APIs without this fix and none with this fix.

NOTE: The following files under modules/javafx.web/src/android and modules/javafx.web/src/ios were not processed by the automated tool. As I have no way to compile them, I chose not to manually fix them either, but doing so would be trivial as a follow-up fix if desired.

modules/javafx.web/src/android/java/com/sun/webkit/Timer.java
modules/javafx.web/src/android/java/com/sun/webkit/WebPage.java
modules/javafx.web/src/android/java/javafx/scene/web/WebEngine.java
modules/javafx.web/src/ios/java/javafx/scene/web/ExportedJavaObject.java
modules/javafx.web/src/ios/java/javafx/scene/web/HTMLEditorSkin.java
modules/javafx.web/src/ios/java/javafx/scene/web/JS2JavaBridge.java
modules/javafx.web/src/ios/java/javafx/scene/web/WebEngine.java

/reviewers 2
/contributor add weijun
/contributor add kcr


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8264139: Suppress removal warnings for Security Manager methods

Reviewers

Contributors

  • Weijun Wang <weijun@openjdk.org>
  • Kevin Rushforth <kcr@openjdk.org>

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jfx pull/528/head:pull/528
$ git checkout pull/528

Update a local copy of the PR:
$ git checkout pull/528
$ git pull https://git.openjdk.java.net/jfx pull/528/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 528

View PR using the GUI difftool:
$ git pr show -t 528

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jfx/pull/528.diff

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Jun 3, 2021

馃憢 Welcome back kcr! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr label Jun 3, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Jun 3, 2021

@kevinrushforth
The number of required reviews for this PR is now set to 2 (with at least 1 of role reviewers).

@openjdk
Copy link

@openjdk openjdk bot commented Jun 3, 2021

@kevinrushforth
Contributor Weijun Wang <weijun@openjdk.org> successfully added.

@openjdk
Copy link

@openjdk openjdk bot commented Jun 3, 2021

@kevinrushforth
Contributor Kevin Rushforth <kcr@openjdk.org> successfully added.

@mlbridge
Copy link

@mlbridge mlbridge bot commented Jun 3, 2021

Webrevs

Copy link
Contributor

@wangweij wangweij left a comment

All change looks good. Some personal style preferences comments.

@@ -9966,7 +9966,7 @@ Accessible getAccessible() {
if (accessible == null) {
accessible = Application.GetApplication().createAccessible();
accessible.setEventHandler(new Accessible.EventHandler() {
@SuppressWarnings({"removal","deprecation"})
@SuppressWarnings("removal")
Copy link
Contributor

@wangweij wangweij Jun 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this "deprecation" already useless before this change?

Copy link
Member Author

@kevinrushforth kevinrushforth Jun 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. The code to which it applied was removed back in JDK 9, but we forgot to remove the annotation.

@@ -412,11 +411,13 @@ private HTTP2Loader(WebPage webPage,
};

// Run the HttpClient in the page's access control context
this.response = AccessController.doPrivileged((PrivilegedAction<CompletableFuture<Void>>) () -> {
@SuppressWarnings("removal")
CompletableFuture<Void> tmpResponse = AccessController.doPrivileged((PrivilegedAction<CompletableFuture<Void>>) () -> {
Copy link
Contributor

@wangweij wangweij Jun 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "var" enough?

Copy link
Member Author

@kevinrushforth kevinrushforth Jun 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'll change it.

public class ModuleHelper {
private static final Method getModuleMethod;
private static final Method getResourceAsStreamMethod;

private static final boolean verbose;

static {
verbose = AccessController.doPrivileged((PrivilegedAction<Boolean>) () ->
Copy link
Contributor

@wangweij wangweij Jun 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can merge this assignment with the declaration on line 38. Or you can keep this so the check of verbose is in the same block with its assignment.

Copy link
Member Author

@kevinrushforth kevinrushforth Jun 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'll keep this one as is to minimize changes.

@@ -41,7 +40,9 @@
private static final int dpiOverride;

static {
dpiOverride = AccessController.doPrivileged((PrivilegedAction<Integer>) () -> Integer.getInteger("com.sun.javafx.screenDPI", 0)).intValue();
@SuppressWarnings("removal")
Copy link
Contributor

@wangweij wangweij Jun 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Combine assignment and declaration?

Copy link
Member Author

@kevinrushforth kevinrushforth Jun 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. This allows the static block to be removed.

public class LinuxArch {

private static final int bits;

static {
bits = AccessController.doPrivileged((PrivilegedAction<Integer>) () -> {
Copy link
Contributor

@wangweij wangweij Jun 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Combine?

Copy link
Member Author

@kevinrushforth kevinrushforth Jun 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. This allows the static block to be removed.

@@ -240,12 +242,14 @@ private static int fwkGetMaximumHTTPConnectionCountPerHost() {
private static final Permission modifyThreadGroupPerm = new RuntimePermission("modifyThreadGroup");
private static final Permission modifyThreadPerm = new RuntimePermission("modifyThread");

@SuppressWarnings("removal")
Copy link
Contributor

@wangweij wangweij Jun 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe move this onto the 1st line inside the method?

@kevinrushforth kevinrushforth requested review from aghaisas and arapte Jun 5, 2021
@aghaisas
Copy link
Collaborator

@aghaisas aghaisas commented Jun 14, 2021

When built with JDK 17ea26 + gradle -PLINT=removal - I cross verified on my macBook (macOS 10.15) that -

  • without this fix - the warnings are generated
  • with this fix - the warnings are not generated

arapte
arapte approved these changes Jun 15, 2021
Copy link
Member

@arapte arapte left a comment

Looks good to me.

@openjdk
Copy link

@openjdk openjdk bot commented Jun 15, 2021

@kevinrushforth This change now passes all automated pre-integration checks.

鈩癸笍 This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8264139: Suppress removal warnings for Security Manager methods

Co-authored-by: Weijun Wang <weijun@openjdk.org>
Co-authored-by: Kevin Rushforth <kcr@openjdk.org>
Reviewed-by: aghaisas, arapte

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 7 new commits pushed to the master branch:

  • 0ffa8e2: 8244075: Accelerator of ContextMenu's MenuItem is not removed when ContextMenu is removed from Scene
  • e6cf1df: 8267094: TreeCell: cancelEvent must return correct editing location
  • ca25036: 8267858: Document that title property in WebEngine gets updated asynchronously
  • 59cf4de: 8267505: {List,Set,Map}PropertyBase::bind should check against identity
  • fe81b9c: 8268120: Allow hardware cursor to be used on Monocle-EGL platforms
  • ee03238: 8268152: gstmpegaudioparse does not provides timestamps for HLS MP3 streams
  • 47700d8: 8267819: CoInitialize/CoUninitialize should be called on same thread

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

鉃★笍 To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready label Jun 15, 2021
@kevinrushforth
Copy link
Member Author

@kevinrushforth kevinrushforth commented Jun 15, 2021

/integrate

@openjdk
Copy link

@openjdk openjdk bot commented Jun 15, 2021

Going to push as commit c81a722.
Since your change was applied there have been 7 commits pushed to the master branch:

  • 0ffa8e2: 8244075: Accelerator of ContextMenu's MenuItem is not removed when ContextMenu is removed from Scene
  • e6cf1df: 8267094: TreeCell: cancelEvent must return correct editing location
  • ca25036: 8267858: Document that title property in WebEngine gets updated asynchronously
  • 59cf4de: 8267505: {List,Set,Map}PropertyBase::bind should check against identity
  • fe81b9c: 8268120: Allow hardware cursor to be used on Monocle-EGL platforms
  • ee03238: 8268152: gstmpegaudioparse does not provides timestamps for HLS MP3 streams
  • 47700d8: 8267819: CoInitialize/CoUninitialize should be called on same thread

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Jun 15, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels Jun 15, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Jun 15, 2021

@kevinrushforth Pushed as commit c81a722.

馃挕 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@kevinrushforth kevinrushforth deleted the 8264139-sm-warnings branch Jun 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
4 participants