RFR: 8304283: Modernize the switch statements in jdk.internal.foreign

Maurizio Cimadamore mcimadamore at openjdk.org
Wed Mar 15 18:39:27 UTC 2023


On Wed, 15 Mar 2023 18:10:29 GMT, Per Minborg <pminborg at openjdk.org> wrote:

> This PR proposes changing old-type switch statements to newer forms of switch.

Overall looks good. I've added a couple of optional comments for your consideration.

src/java.base/share/classes/jdk/internal/foreign/abi/CallingSequenceBuilder.java line 208:

> 206:     static boolean isUnbox(Binding binding) {
> 207:         return switch (binding) {
> 208:             case Binding.VMStore unused -> true;

I wonder... here it might be better to capture the box/unbox nature of a binding in a virtual method in the binding class? E.g. isBox(), isUnbox() ?

src/java.base/share/classes/jdk/internal/foreign/abi/riscv64/linux/TypeClass.java line 112:

> 110:                     return flatten(sequenceLayout.elementLayout()).mul(elementCount);
> 111:                 }
> 112:                 case null, default -> throw new IllegalStateException("Cannot get here: " + layout);

Since the default throws, and the switch w/o a `case null` also throws, do we need the `case null` here?

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

Marked as reviewed by mcimadamore (Reviewer).

PR: https://git.openjdk.org/jdk/pull/13047


More information about the core-libs-dev mailing list