diff --git a/src/java.base/share/classes/java/lang/constant/MethodHandleDesc.java b/src/java.base/share/classes/java/lang/constant/MethodHandleDesc.java index 18786481fa6..0ac45657d5f 100644 --- a/src/java.base/share/classes/java/lang/constant/MethodHandleDesc.java +++ b/src/java.base/share/classes/java/lang/constant/MethodHandleDesc.java @@ -82,15 +82,11 @@ public sealed interface MethodHandleDesc ClassDesc owner, String name, String lookupDescriptor) { - switch (kind) { - case GETTER: - case SETTER: - case STATIC_GETTER: - case STATIC_SETTER: - return ofField(kind, owner, name, ClassDesc.ofDescriptor(lookupDescriptor)); - default: - return new DirectMethodHandleDescImpl(kind, owner, name, MethodTypeDesc.ofDescriptor(lookupDescriptor)); - } + return switch (kind) { + case GETTER, SETTER, STATIC_GETTER, STATIC_SETTER + -> ofField(kind, owner, name, ClassDesc.ofDescriptor(lookupDescriptor)); + default -> new DirectMethodHandleDescImpl(kind, owner, name, MethodTypeDesc.ofDescriptor(lookupDescriptor)); + }; } /** @@ -122,23 +118,13 @@ public sealed interface MethodHandleDesc ClassDesc owner, String name, MethodTypeDesc lookupMethodType) { - switch (kind) { - case GETTER: - case SETTER: - case STATIC_GETTER: - case STATIC_SETTER: - throw new IllegalArgumentException(kind.toString()); - case VIRTUAL: - case SPECIAL: - case INTERFACE_VIRTUAL: - case INTERFACE_SPECIAL: - case INTERFACE_STATIC: - case STATIC: - case CONSTRUCTOR: - return new DirectMethodHandleDescImpl(kind, owner, name, lookupMethodType); - default: - throw new IllegalArgumentException(kind.toString()); - } + return switch (kind) { + case GETTER, SETTER, STATIC_GETTER, STATIC_SETTER + -> throw new IllegalArgumentException(kind.toString()); + case VIRTUAL, SPECIAL, INTERFACE_VIRTUAL, INTERFACE_SPECIAL, INTERFACE_STATIC, STATIC, CONSTRUCTOR + -> new DirectMethodHandleDescImpl(kind, owner, name, lookupMethodType); + default -> throw new IllegalArgumentException(kind.toString()); + }; } /**