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

8263233: Update java.net and java.nio to use instanceof pattern variable #2890

Closed
wants to merge 3 commits into from

Conversation

@pconcannon
Copy link
Contributor

@pconcannon pconcannon commented Mar 9, 2021

Hi,

Could someone please review my code for updating the code in the java.net and java.nio packages to make use of the instanceof pattern variable?

Kind regards,
Patrick


Progress

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

Issue

  • JDK-8263233: Update java.net and java.nio to use instanceof pattern variable

Reviewers

Download

$ git fetch https://git.openjdk.java.net/jdk pull/2890/head:pull/2890
$ git checkout pull/2890

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Mar 9, 2021

👋 Welcome back pconcannon! 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.

Loading

@openjdk openjdk bot added the rfr label Mar 9, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Mar 9, 2021

@pconcannon The following label will be automatically applied to this pull request:

  • net

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

Loading

@openjdk openjdk bot added the net label Mar 9, 2021
@mlbridge
Copy link

@mlbridge mlbridge bot commented Mar 9, 2021

Webrevs

Loading

dfuch
dfuch approved these changes Mar 9, 2021
Copy link
Member

@dfuch dfuch left a comment

LGTM.

Loading

@openjdk
Copy link

@openjdk openjdk bot commented Mar 9, 2021

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

8263233: Update java.net and java.nio to use instanceof pattern variable

Reviewed-by: dfuchs, bpb, chegar, 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 15 new commits pushed to the master branch:

  • 3fe8a46: 8263170: ComboBoxModel documentation refers to a nonexistent type
  • d8a9c3c: 8263002: Remove CDS MiscCode region
  • 67ea3bd: 8263102: Expand documention of Method.isBridge
  • d0c1aec: 8263140: Japanese chars garble in console window in HSDB
  • 70342e8: 8262520: Add SA Command Line Debugger support to connect to debug server
  • e5ce97b: 8263206: assert(*error_msg != '\0') failed: Must have error_message while parsing -XX:CompileCommand=unknown
  • 3212f80: 8261937: LambdaForClassInBaseArchive: SimpleApp$$Lambda$1 missing
  • 2218e72: 8262486: Merge trivial JDWP agent changes from the loom repo to the jdk repo
  • 86fac95: 8263142: Delete unused entry points in libawt/libawt_xawt/libawt_headless
  • b7f0b3f: 8252173: Use handles instead of jobjects in modules.cpp
  • ... and 5 more: https://git.openjdk.java.net/jdk/compare/0bc45625b0980c090e09edf73aa4800e20605035...master

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.

Loading

@openjdk openjdk bot added the ready label Mar 9, 2021
…; removed superfluous whitespace in java/net/Inet6Address
bplb
bplb approved these changes Mar 9, 2021
Copy link
Member

@bplb bplb left a comment

Looks fine.

Loading

@@ -216,9 +216,8 @@ public synchronized void bind(SocketAddress addr) throws SocketException {
throw new SocketException("already bound");
if (addr == null)
addr = new InetSocketAddress(0);
if (!(addr instanceof InetSocketAddress))
Copy link

@msheppar msheppar Mar 9, 2021

Choose a reason for hiding this comment

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

in the context of this type of change the negative logic is a little obtuse or disjoint in the new style variable declaration, and its subsequent use. I'd find it a more natural flow and easier to read with the instanceof pattern prefacing a block in which the variable is used
if (addr instanceof InetSocketAddress epoint) {
// a block which is using the epoint variable
if (epoint.isUnresolved)
throw new SocketException("Unresolved address");
InetAddress iaddr = epoint.getAddress;
etc, etc ...
} else {
throw new IllegalArgumentException("Unsupported address type!");
}

Loading

Copy link
Member

@dfuch dfuch Mar 9, 2021

Choose a reason for hiding this comment

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

The disadvantage is that it would add another level of braces.

Loading

Copy link

@msheppar msheppar Mar 9, 2021

Choose a reason for hiding this comment

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

maybe ... I find it would provide an easier flow to code ... an "easy on the eye" call flow linkage - the variable is declared and then used .... instead of the disconnect of throwing an exception or non immediate use of the variable.

but sure, isn't code somewhat idiosyncratic!!

Loading

Copy link
Member

@ChrisHegarty ChrisHegarty Mar 10, 2021

Choose a reason for hiding this comment

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

The first few times I looked at this pattern, I did stumble over it somewhat. But since then, I find it natural enough and easy to follow. Maybe the concern is transient in nature, until the instanceof pattern matching feature is more widely used.

Loading

dfuch
dfuch approved these changes Mar 9, 2021
@@ -216,9 +216,8 @@ public synchronized void bind(SocketAddress addr) throws SocketException {
throw new SocketException("already bound");
if (addr == null)
addr = new InetSocketAddress(0);
if (!(addr instanceof InetSocketAddress))
Copy link
Member

@dfuch dfuch Mar 9, 2021

Choose a reason for hiding this comment

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

The disadvantage is that it would add another level of braces.

Loading

Copy link
Member

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

Good to see the new feature being used. It definitely enhances readability overall.

Loading

@pconcannon
Copy link
Contributor Author

@pconcannon pconcannon commented Mar 10, 2021

/integrate

Loading

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

@openjdk openjdk bot commented Mar 10, 2021

@pconcannon Since your change was applied there have been 15 commits pushed to the master branch:

  • 3fe8a46: 8263170: ComboBoxModel documentation refers to a nonexistent type
  • d8a9c3c: 8263002: Remove CDS MiscCode region
  • 67ea3bd: 8263102: Expand documention of Method.isBridge
  • d0c1aec: 8263140: Japanese chars garble in console window in HSDB
  • 70342e8: 8262520: Add SA Command Line Debugger support to connect to debug server
  • e5ce97b: 8263206: assert(*error_msg != '\0') failed: Must have error_message while parsing -XX:CompileCommand=unknown
  • 3212f80: 8261937: LambdaForClassInBaseArchive: SimpleApp$$Lambda$1 missing
  • 2218e72: 8262486: Merge trivial JDWP agent changes from the loom repo to the jdk repo
  • 86fac95: 8263142: Delete unused entry points in libawt/libawt_xawt/libawt_headless
  • b7f0b3f: 8252173: Use handles instead of jobjects in modules.cpp
  • ... and 5 more: https://git.openjdk.java.net/jdk/compare/0bc45625b0980c090e09edf73aa4800e20605035...master

Your commit was automatically rebased without conflicts.

Pushed as commit fdd3941.

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

Loading

@pconcannon pconcannon deleted the JDK-8263233 branch May 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment