mirror of
https://github.com/openjdk/jdk.git
synced 2026-04-29 00:02:34 +00:00
8365620: Using enhanced switch in MethodHandleDesc
Reviewed-by: liach
This commit is contained in:
parent
2427c901b3
commit
a668f437e4
@ -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());
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user