On Thu, 14 Aug 2025 04:49:28 GMT, Shaojin Wen <s...@openjdk.org> wrote:

> In MethodHandleDesc, the `ofField` method uses enhanced switch, while the 
> `of` and `ofMethod` methods use traditional switch. The same class should 
> have a unified style.

src/java.base/share/classes/java/lang/constant/MethodHandleDesc.java line 123:

> 121:             case VIRTUAL, SPECIAL, INTERFACE_VIRTUAL, INTERFACE_SPECIAL, 
> INTERFACE_STATIC, STATIC, CONSTRUCTOR
> 122:                     -> new DirectMethodHandleDescImpl(kind, owner, name, 
> lookupMethodType);
> 123:             default -> throw new 
> IllegalArgumentException(kind.toString());

I recommend using `case GETTER, SETTER, STATIC_GETTER, STATIC_SETTER` 
explicitly in case we have more kinds in the future, this will become a compile 
error and remind us to update. And we can remove the default branch.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26769#discussion_r2278135364

Reply via email to