Skip to content

Conversation

@dfuch
Copy link
Member

@dfuch dfuch commented Apr 11, 2025

Please find her a patch that deprecate networking permission classes for removal. The method URL::getPermission now serves little purpose and is also deprecated. That method was overridden in subclasses and specified to return some of the deprecated permissions.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change requires CSR request JDK-8354406 to be approved

Issues

  • JDK-8353642: Deprecate URL::getPermission method and networking permission classes for removal (Enhancement - P3)
  • JDK-8354406: Deprecate URL::getPermission method and networking permission classes for removal (CSR)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/24592/head:pull/24592
$ git checkout pull/24592

Update a local copy of the PR:
$ git checkout pull/24592
$ git pull https://git.openjdk.org/jdk.git pull/24592/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 24592

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/24592.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 11, 2025

👋 Welcome back dfuchs! 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
Copy link

openjdk bot commented Apr 11, 2025

@dfuch 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:

8353642: Deprecate URL::getPermission method and networking permission classes for removal

Reviewed-by: djelinski, iris, mullan, michaelm

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 53 new commits pushed to 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 rfr Pull request is ready for review label Apr 11, 2025
@openjdk
Copy link

openjdk bot commented Apr 11, 2025

@dfuch The following labels will be automatically applied to this pull request:

  • net
  • nio
  • security

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added security security-dev@openjdk.org nio nio-dev@openjdk.org net net-dev@openjdk.org labels Apr 11, 2025
@mlbridge
Copy link

mlbridge bot commented Apr 11, 2025

Webrevs

@openjdk openjdk bot added the csr Pull request needs approved CSR before integration label Apr 11, 2025
@dfuch
Copy link
Member Author

dfuch commented Apr 11, 2025

The CSR is also ready to be reviewed at https://bugs.openjdk.org/browse/JDK-8354406

* {@link UnsupportedOperationException}, or return
* {@link java.security.AllPermission}.
*/
@Deprecated(since = "25")
Copy link
Member

Choose a reason for hiding this comment

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

can this (and all other getPermission methods) be "forRemoval=true"?

Copy link
Member Author

Choose a reason for hiding this comment

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

Possibly. @AlanBateman may have some thoughts on this.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should at least consider deprecating URLConnection.getPermission and HttpURLConnection.getPermission for removal, only because I don't immediately see the advantage of doing it in two steps for these two APIs.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks - I will do that then

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

}
return this.sp.implies(that.sp);
@SuppressWarnings("removal")
var result = this.sp.implies(that.sp);
Copy link
Member

Choose a reason for hiding this comment

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

Will we need to rewrite this code without SocketPermissions? Can we remove it, maybe? It is only used by CodeSource.implies, which is not used by the JDK (but may be used elsewhere).

Copy link
Member

Choose a reason for hiding this comment

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

also the JavaDoc of the implies method references the SocketPermission. That will also need to be cleaned up at some point.

Copy link
Member Author

Choose a reason for hiding this comment

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

That will be left over for someone in security-libs to cleanup this code at their convenience before we remove SocketException.

Hmmm... If the public API references SocketException we might have to deprecate in this PR too. Not sure what the implications are. Maybe @seanjmullan can advise.

*/

@SuppressWarnings("removal")
@Deprecated(since = "25", forRemoval = true)
Copy link
Member

Choose a reason for hiding this comment

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

this class is internal, no need to deprecate

Copy link
Member Author

@dfuch dfuch Apr 11, 2025

Choose a reason for hiding this comment

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

It helps getting warnings at the place where the class is used.

@djelinski
Copy link
Member

The GHA failure (Windows) appears to be related.

@dfuch
Copy link
Member Author

dfuch commented Apr 11, 2025

The GHA failure (Windows) appears to be related.

Yes - I missed one windows specific file in my original patch. I have a test running in the CI and I am waiting for it to pass before updating the PR.

if (this.sp == null) {
this.sp = new SocketPermission(thisHost, "resolve");
@SuppressWarnings("removal")
var _ = this.sp = new SocketPermission(thisHost, "resolve");
Copy link
Member

Choose a reason for hiding this comment

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

What's the reason for the var _ = bit ?

Copy link
Member Author

@dfuch dfuch Apr 11, 2025

Choose a reason for hiding this comment

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

@SuppressWarnings can not be applied to a an expression - it needs a (variable/method/class) declaration

@dfuch dfuch changed the title 8353642: Deprecate networking permission classes for removal 8353642: Deprecate URL::getPermission method and networking permission classes for removal Apr 11, 2025
@dfuch
Copy link
Member Author

dfuch commented Apr 11, 2025

The GHA failure (Windows) appears to be related.

Should be fixed now

Copy link
Member

@Michael-Mc-Mahon Michael-Mc-Mahon left a comment

Choose a reason for hiding this comment

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

Looks fine to me.

Copy link
Member

@djelinski djelinski left a comment

Choose a reason for hiding this comment

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

LGTM.

@dfuch
Copy link
Member Author

dfuch commented May 8, 2025

After discussion with @seanjmullan we decided to revert the changes to SocketPermission and CodeSource from this PR. Deprecation of SocketPermission will be the object of another RFE (JDK-8356557) - once we have decided what to do with CodeSource::implies.

* relevant
*/
@Override
@Deprecated(since = "25", forRemoval = true)
Copy link
Member

Choose a reason for hiding this comment

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

Is this annotation required or more as a reminder that the superclass method is deprecated?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it's needed because the superclass method is deprecated for removal. Will double check.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes - it is needed. If you override a deprecated method you need to carry the deprecation annotation over. Here is what I got when I tried to remove the annotation on HttpURLConnection::getPermission() (the same error occurred on any subclass where I attempted to remove the annotation):

java/net/HttpURLConnection.java:615: warning: [dep-ann] deprecated item is not annotated with @Deprecated
    public Permission getPermission() throws IOException {
                      ^
error: warnings found and -Werror specified

* as the Security Manager is no longer supported.
*/
@Deprecated(since = "25", forRemoval = true)
@SuppressWarnings("removal")
Copy link
Member

Choose a reason for hiding this comment

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

Do you still need this annotation now that SocketPermission is not deprecated for removal?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah - good point - I will double check.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes - it is needed as well. Apparently if you override a deprecated method you need both @Deprecated and @SuppressWarning:

src/java.base/share/classes/java/net/HttpURLConnection.java:615: warning: [removal] getPermission() in URLConnection has been deprecated and marked for removal
    public Permission getPermission() throws IOException {
                      ^
error: warnings found and -Werror specified

Copy link
Member

Choose a reason for hiding this comment

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

Ok, but seems redundant.

@openjdk openjdk bot added ready Pull request is ready to be integrated and removed csr Pull request needs approved CSR before integration labels May 9, 2025
@dfuch
Copy link
Member Author

dfuch commented May 12, 2025

/integrate

@openjdk
Copy link

openjdk bot commented May 12, 2025

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

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label May 12, 2025
@openjdk openjdk bot closed this May 12, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels May 12, 2025
@openjdk
Copy link

openjdk bot commented May 12, 2025

@dfuch Pushed as commit 45dfc2c.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integrated Pull request has been integrated net net-dev@openjdk.org nio nio-dev@openjdk.org security security-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

6 participants