RFR: 8350118: Simplify the layout access VarHandle

Maurizio Cimadamore mcimadamore at openjdk.org
Fri Feb 21 14:53:57 UTC 2025


On Fri, 21 Feb 2025 13:53:47 GMT, Chen Liang <liach at openjdk.org> wrote:

>> src/java.base/share/classes/jdk/internal/foreign/Utils.java line 77:
>> 
>>> 75: 
>>> 76:     private static MethodHandle computeFilterHandle(int index) {
>>> 77:         MethodHandles.Lookup lookup = MethodHandles.lookup();
>> 
>> please break this big conditional up!
>
> This is a one-time cold path initializer so I did not care too much about its size. How should I break it up?

I mean - using a single expression which is a conditional with two big switches seems quite unreadable.I suggest to move the `VH_FILTERS[index] = ` assignment out of the `computeFilterHandle` method. Then, rewrite `computeFilterHandle` as:


if (addressSize != 4) {
    return switch ...
} else {
    return switch ...
}

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23720#discussion_r1965609458


More information about the build-dev mailing list