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

Maurizio Cimadamore mcimadamore at openjdk.java.net
Mon Apr 26 13:55:30 UTC 2021


On Sun, 25 Apr 2021 09:20:49 GMT, Guoxiong Li <gli at openjdk.org> wrote:

> 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.

Looks good, one minor nit comment

src/jdk.compiler/share/classes/com/sun/tools/javac/code/Scope.java line 756:

> 754: 
> 755:         protected Scope finalizeSingleScope(Scope impScope) {
> 756:             if (impScope instanceof FilterImportScope filterImportScope && impScope.owner.kind == Kind.TYP &&

break vertically on each `&&` ?

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ArgumentAttr.java line 754:

> 752:         @Override
> 753:         public boolean equals(Object obj) {
> 754:             return (obj instanceof UniquePos uniquePos)

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

src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/PoolConstant.java line 190:

> 188:             @Override
> 189:             public boolean equals(Object obj) {
> 190:                 return (obj instanceof BsmKey key)

BsmKey smells of records too...

-------------

Marked as reviewed by mcimadamore (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/3674


More information about the compiler-dev mailing list