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

8265900: Use pattern matching for instanceof at module jdk.compiler(part 2) #3674

Closed
wants to merge 2 commits into from

Conversation

lgxbslgx
Copy link
Member

@lgxbslgx lgxbslgx commented Apr 25, 2021

Hi all,

This series of patches update the code of the module jdk.compiler by using the pattern matching for instanceof.

This patch would revise the following packages:

com.sun.tools.javac.code
com.sun.tools.javac.comp
com.sun.tools.javac.jvm
com.sun.tools.javac.parser
com.sun.tools.javac.processing

Thank you for taking the time to review.

--
Best Regards,
Guoxiong.


Progress

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

Issue

  • JDK-8265900: Use pattern matching for instanceof at module jdk.compiler(part 2)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 3674

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 25, 2021

👋 Welcome back gli! 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 25, 2021

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

  • compiler

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.

@openjdk openjdk bot added the compiler compiler-dev@openjdk.org label Apr 25, 2021
@lgxbslgx lgxbslgx marked this pull request as ready for review April 25, 2021 09:29
@openjdk openjdk bot added the rfr Pull request is ready for review label Apr 25, 2021
@mlbridge
Copy link

mlbridge bot commented Apr 25, 2021

Webrevs

Copy link
Contributor

@mcimadamore mcimadamore left a comment

Choose a reason for hiding this comment

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

Looks good, one minor nit comment

@@ -753,8 +753,8 @@ public void finalizeScope() {
}

protected Scope finalizeSingleScope(Scope impScope) {
if (impScope instanceof FilterImportScope && impScope.owner.kind == Kind.TYP &&
((FilterImportScope) impScope).isStaticallyImported()) {
if (impScope instanceof FilterImportScope filterImportScope && impScope.owner.kind == Kind.TYP &&
Copy link
Contributor

Choose a reason for hiding this comment

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

break vertically on each && ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

} else {
return false;
}
return (obj instanceof UniquePos uniquePos)
Copy link
Contributor

Choose a reason for hiding this comment

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

For another day - UniquePos can be a record :-)

} else {
return false;
}
return (obj instanceof BsmKey key)
Copy link
Contributor

Choose a reason for hiding this comment

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

BsmKey smells of records too...

@openjdk
Copy link

openjdk bot commented Apr 26, 2021

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

8265900: Use pattern matching for instanceof at module jdk.compiler(part 2)

Reviewed-by: mcimadamore

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

  • 68011c6: 8265928: G1: Update copyright in several files
  • 222f9f0: 8265682: G1: Mutex::_name dangling in HeapRegionRemSet references after JDK-8264146
  • 2b09ff2: 8232765: NullPointerException at Types.eraseNotNeeded() when compiling a class
  • b9f66d9: 8264188: Improve handling of assembly files in the JDK
  • c3ac690: 8261759: ZGC: ZWorker Threads Continue Marking After System.exit() called
  • 31abe68: 8265116: ZGC: Steal local stacks instead of flushing them
  • 83364a4: 8264258: Unknown lookups in the java package give misleading compilation errors
  • a9367db: 8265127: ZGC: Fix incorrect reporting of reclaimed memory
  • 1580a47: 8265911: assert(comp != __null) failed: Compiler instance missing
  • 9647fb0: 8265689: JVMCI: InternalError: Class java.lang.Object does not implement interface jdk.vm.ci.meta.JavaType
  • ... and 9 more: https://git.openjdk.java.net/jdk/compare/f6e22d14e3ee529f21ab8747cfbafe72b906ec68...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.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@mcimadamore) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Apr 26, 2021
@mlbridge
Copy link

mlbridge bot commented Apr 26, 2021

Mailing list message from Brian Goetz on compiler-dev:

Also, FYI: we had a discussion over a similar topic over on corelibs,
and settled on making the binding variable names a little less "fussy",
especially in patterns like Object::equals (calling it `that` or `other`
is fine; we don't have to call it `standardFinalManager`.)? These are
convenience variables with small scopes; they don't need super-specific
names (and the super-specific names often make the code harder to
read.)? You don't have to go and change them, just keep this in mind for
next time.

On 4/26/2021 9:55 AM, Maurizio Cimadamore wrote:

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20210426/a7516187/attachment.htm>

@mlbridge
Copy link

mlbridge bot commented Apr 26, 2021

Mailing list message from Guoxiong Li on compiler-dev:

Hi Brian,

Thank you for your reminder. It is a good suggestion about code readability.

--
Best Regards,
Guoxiong.

On Mon, Apr 26, 2021 at 10:04 PM Brian Goetz <brian.goetz at oracle.com> wrote:

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20210426/76805a58/attachment.htm>

@lgxbslgx
Copy link
Member Author

@mcimadamore I updated the code. Could I get your help to re-review and sponsor? Thanks a lot.

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Apr 26, 2021
@openjdk
Copy link

openjdk bot commented Apr 26, 2021

@lgxbslgx
Your change (at version 55de5a0) is now ready to be sponsored by a Committer.

@mcimadamore
Copy link
Contributor

mcimadamore commented Apr 26, 2021

/sponsor

@openjdk openjdk bot closed this Apr 26, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed sponsor Pull request is ready to be sponsored ready Pull request is ready to be integrated rfr Pull request is ready for review labels Apr 26, 2021
@openjdk
Copy link

openjdk bot commented Apr 26, 2021

@mcimadamore @lgxbslgx Since your change was applied there have been 22 commits pushed to the master branch:

  • 851b219: 8265901: Use pattern matching for instanceof at module jdk.compiler(part 3)
  • fb8f0c5: 8261168: Convert javadoc tool to use Stream.toList()
  • 8559a53: 8265394: G1: Improve assert in HeapRegion::reset_not_compacted_after_full_gc
  • 68011c6: 8265928: G1: Update copyright in several files
  • 222f9f0: 8265682: G1: Mutex::_name dangling in HeapRegionRemSet references after JDK-8264146
  • 2b09ff2: 8232765: NullPointerException at Types.eraseNotNeeded() when compiling a class
  • b9f66d9: 8264188: Improve handling of assembly files in the JDK
  • c3ac690: 8261759: ZGC: ZWorker Threads Continue Marking After System.exit() called
  • 31abe68: 8265116: ZGC: Steal local stacks instead of flushing them
  • 83364a4: 8264258: Unknown lookups in the java package give misleading compilation errors
  • ... and 12 more: https://git.openjdk.java.net/jdk/compare/f6e22d14e3ee529f21ab8747cfbafe72b906ec68...master

Your commit was automatically rebased without conflicts.

Pushed as commit 082abbd.

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

@lgxbslgx lgxbslgx deleted the JDK-8265900 branch April 26, 2021 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler compiler-dev@openjdk.org integrated Pull request has been integrated
2 participants