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

Andrey Turbanov aturbanov at openjdk.org
Mon Jun 26 20:58:06 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

src/java.base/share/classes/java/lang/invoke/MemberName.java line 995:

> 993:                 return result;
> 994:             ReflectiveOperationException ex = result.makeAccessException();
> 995:             if (ex instanceof IllegalAccessException iae)  throw iae;

Suggestion:

            if (ex instanceof IllegalAccessException iae) throw iae;

src/java.base/share/classes/java/lang/invoke/MethodHandleStatics.java line 189:

> 187:     static Error uncaughtException(Throwable ex) {
> 188:         if (ex instanceof Error error)  throw error;
> 189:         if (ex instanceof RuntimeException re)  throw re;

Suggestion:

        if (ex instanceof Error error) throw error;
        if (ex instanceof RuntimeException re) throw re;

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14642#discussion_r1242756653
PR Review Comment: https://git.openjdk.org/jdk/pull/14642#discussion_r1242757121


More information about the core-libs-dev mailing list