RFR: 8310849: Pattern matching for instanceof and arrayType cleanup in j.l.invoke and j.l.reflect [v3]

Mandy Chung mchung at openjdk.org
Mon Jun 26 20:08:07 UTC 2023


On Mon, 26 Jun 2023 13:51:25 GMT, Chen Liang <liach at openjdk.org> wrote:

>> This patch touches java.lang.reflect and java.lang.invoke packages. It replaces instanceof + cast with pattern matching and updates  Array.newInstance().getClass() patterns with arrayType() for obtaining array types of a class.
>
> Chen Liang has updated the pull request incrementally with one additional commit since the last revision:
> 
>   simplify equals by replacing if with and operators

Looks okay to me.

src/java.base/share/classes/java/lang/invoke/MethodType.java line 899:

> 897:             return equals(mt);
> 898:         }
> 899:         if (x instanceof ConcurrentWeakInternSet.WeakEntry<?> e && e.get() instanceof MethodType mt) {

Nit: break this long line into 2.

src/java.base/share/classes/sun/reflect/generics/reflectiveObjects/ParameterizedTypeImpl.java line 189:

> 187:                                                         that.getActualTypeArguments());
> 188:                 for (Type t : actualTypeArguments) {
> 189:                     System.out.printf("\t\t%s%s%n", t, t.getClass());

Surprised that these debugging statements are unnoticed for so many years.

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

Marked as reviewed by mchung (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/14642#pullrequestreview-1499147829
PR Review Comment: https://git.openjdk.org/jdk/pull/14642#discussion_r1242592457
PR Review Comment: https://git.openjdk.org/jdk/pull/14642#discussion_r1242595216


More information about the core-libs-dev mailing list