8268124: Update java.lang to use switch expressions

Reviewed-by: naoto, darcy, mchung, iris, lancea, dfuchs
This commit is contained in:
Patrick Concannon 2021-06-10 11:12:37 +00:00
parent a187fcc3ec
commit d43c8a74b3
22 changed files with 421 additions and 551 deletions

View file

@ -156,15 +156,13 @@ public sealed interface MethodHandleDesc
ClassDesc owner,
String fieldName,
ClassDesc fieldType) {
MethodTypeDesc mtr;
switch (kind) {
case GETTER: mtr = MethodTypeDesc.of(fieldType, owner); break;
case SETTER: mtr = MethodTypeDesc.of(CD_void, owner, fieldType); break;
case STATIC_GETTER: mtr = MethodTypeDesc.of(fieldType); break;
case STATIC_SETTER: mtr = MethodTypeDesc.of(CD_void, fieldType); break;
default:
throw new IllegalArgumentException(kind.toString());
}
MethodTypeDesc mtr = switch (kind) {
case GETTER -> MethodTypeDesc.of(fieldType, owner);
case SETTER -> MethodTypeDesc.of(CD_void, owner, fieldType);
case STATIC_GETTER -> MethodTypeDesc.of(fieldType);
case STATIC_SETTER -> MethodTypeDesc.of(CD_void, fieldType);
default -> throw new IllegalArgumentException(kind.toString());
};
return new DirectMethodHandleDescImpl(kind, owner, fieldName, mtr);
}