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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8332181: Deprecate for removal the MulticastSocket.send(DatagramPacket, byte) and setTTL/getTTL methods on DatagramSocketImpl and MulticastSocket #19242

Closed
wants to merge 5 commits into from

Conversation

jaikiran
Copy link
Member

@jaikiran jaikiran commented May 15, 2024

Can I please get a review of this change which proposes to deprecate for removal 3 methods on java.net.MulticastSocket? This addresses https://bugs.openjdk.org/browse/JDK-8332181.

As noted in that issue these methods have been deprecated since Java 1.2 and 1.4 days. They currently have replacement methods (noted in their javadoc) which have been in use for several releases. This commit updates these deprecated methods to deprecated for removal, to allow for their removal in a future release.

No new tests have been added and existing tests in tier1, tier2 and tier3 continue to pass.


Progress

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

Issues

  • JDK-8332181: Deprecate for removal the MulticastSocket.send(DatagramPacket, byte) and setTTL/getTTL methods on DatagramSocketImpl and MulticastSocket (Bug - P4)
  • JDK-8332261: Deprecate for removal the MulticastSocket.send(DatagramPacket, byte) and setTTL/getTTL methods on DatagramSocketImpl and MulticastSocket (CSR)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 19242

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

Using diff file

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

Webrev

Link to Webrev Comment

Sorry, something went wrong.

…tTTL and the 2-arg send methods
@bridgekeeper
Copy link

bridgekeeper bot commented May 15, 2024

👋 Welcome back jpai! 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 May 15, 2024

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

8332181: Deprecate for removal the MulticastSocket.send(DatagramPacket, byte) and setTTL/getTTL methods on DatagramSocketImpl and MulticastSocket

Reviewed-by: dfuchs, iris, alanb

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 3 new commits pushed to the master branch:

  • b78613b: 8332154: Memory leak in SynchronousQueue
  • 7652f98: 8331885: C2: meet between unloaded and speculative types is not symmetric
  • d6b7f9b: 8331851: Add specific regression leap year tests for Calendar.roll()

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 csr Pull request needs approved CSR before integration rfr Pull request is ready for review labels May 15, 2024
@openjdk
Copy link

openjdk bot commented May 15, 2024

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

  • net
  • nio

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 nio nio-dev@openjdk.org net net-dev@openjdk.org labels May 15, 2024
@jaikiran
Copy link
Member Author

A CSR has been drafted for this change and is available for review here https://bugs.openjdk.org/browse/JDK-8332261.

@mlbridge
Copy link

mlbridge bot commented May 15, 2024

Webrevs

@robaho
Copy link
Contributor

robaho commented May 15, 2024

Part of what makes Java so great is that you can take a Java 1 program and run it under Java 22? with no modifications?

What does it cost to keep these methods around?

@jaikiran
Copy link
Member Author

Hello Robert,

Part of what makes Java so great is that you can take a Java 1 program and run it under Java 22? with no modifications?

What does it cost to keep these methods around?

In this case, we do not want the applications to be using these methods. These methods accept a ttl value as byte. As noted in the javadoc of setTTL() method:

The ttl is an unsigned 8-bit quantity, and so must be in the range {@code 0 <= ttl <= 0xFF }

The byte type doesn't allow for these values to be accomodated. That's why those methods were deprecated very long back in favour of the ones noted in their javadoc.

@robaho
Copy link
Contributor

robaho commented May 17, 2024

That makes sense - thanks. I agree it is very, very old - just wanted more to understand the rationale as even though Java has deprecated a lot - I am not aware of any core removals - but only anecdotally.

@@ -652,6 +652,7 @@ public Set<SocketOption<?>> supportedOptions() {

@Deprecated
@Override
@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.

Instead of adding @SuppressWarning("removal") here (and at other places below) - would it make sense to update the @Deprecated annotation and add 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.

We will still have to add the @SuppressWarning("removal") to these methods otherwise the compilation generates a warning which fails the build:

java.base/share/classes/java/net/NetMulticastSocket.java:655: warning: [removal] setTTL(byte) in MulticastSocket has been deprecated and marked for removal
    public void setTTL(byte ttl) throws IOException {
                ^
java.base/share/classes/java/net/NetMulticastSocket.java:673: warning: [removal] getTTL() in MulticastSocket has been deprecated and marked for removal
    public byte getTTL() throws IOException {
                ^
error: warnings found and -Werror specified
1 error
2 warnings

I went ahead and updated these internal NetMulticastSocket and DatagramSocketAdaptor classes to add the forRemoval attribute to the @Deprecated annotation to keep it consistent.

Copy link
Member

Choose a reason for hiding this comment

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

Ah - thank you. I had hoped that adding forRemoval = true to the annotation would allow us to get rid of the SuppressWarning.

Copy link
Member

@irisclark irisclark left a comment

Choose a reason for hiding this comment

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

From the JCP POV, these changes look fine. These changes match the associated CSR, which I've also Reviewed.

@jaikiran
Copy link
Member Author

Thank you Iris and Daniel for the reviews. I've moved the CSR to Finalized.

@AlanBateman
Copy link
Contributor

I think DatagramSocketImpl.getTTL/setTTL will need to be deprecated for removal at the same time.

Also I assume @deprecated can be dropped from DatagramSocketAdaptor and NetMulticastSocket, they just override or call the deprecated methods so should only need @SuppressWarnings("removal").

@jaikiran jaikiran changed the title 8332181: Deprecate for removal the java.net.MulticastSocket.setTTL/getTTL and the 2-arg send methods 8332181: Deprecate for removal the MulticastSocket.send(DatagramPacket, byte) and setTTL/getTTL methods on DatagramSocketImpl and MulticastSocket May 20, 2024
@jaikiran
Copy link
Member Author

Hello Alan,

I think DatagramSocketImpl.getTTL/setTTL will need to be deprecated for removal at the same time.

I have now updated the PR to deprecate for removal these methods too. I have updated the CSR to note this change.

Also I assume @deprecated can be dropped from DatagramSocketAdaptor and NetMulticastSocket, they just override or call the deprecated methods so should only need @SuppressWarnings("removal").

Done.

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

Thank you everyone for the reviews. The CSR has been approved. I'll go ahead with the integration now.

@jaikiran
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented May 21, 2024

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

  • f5ab7df: 8332494: java/util/zip/EntryCount64k.java failing with java.lang.RuntimeException: '\A\Z' missing from stderr
  • 9f77793: 8332495: java/util/logging/LoggingDeadlock2.java fails with AssertionError: Some tests failed
  • fb45bab: 8075917: The regression-swing case failed as the text on label is not painted red with the GTK L&F
  • 6e80512: 8332545: Fix handling of HTML5 entities in Markdown comments
  • b78613b: 8332154: Memory leak in SynchronousQueue
  • 7652f98: 8331885: C2: meet between unloaded and speculative types is not symmetric
  • d6b7f9b: 8331851: Add specific regression leap year tests for Calendar.roll()

Your commit was automatically rebased without conflicts.

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

openjdk bot commented May 21, 2024

@jaikiran Pushed as commit ce99198.

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

@jaikiran jaikiran deleted the 8332181 branch May 21, 2024 07:15
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
Development

Successfully merging this pull request may close these issues.

None yet

5 participants