8267670: Update java.io, java.math, and java.text to use switch expressions

Reviewed-by: darcy, chegar, naoto, iris, dfuchs, lancea, vtewari
This commit is contained in:
Patrick Concannon 2021-06-01 10:14:56 +00:00
parent f5634fe39d
commit 4eb216824f
11 changed files with 161 additions and 349 deletions

View file

@ -110,19 +110,18 @@ public class ObjectStreamField
this.unshared = unshared;
this.field = null;
switch (signature.charAt(0)) {
case 'Z': type = Boolean.TYPE; break;
case 'B': type = Byte.TYPE; break;
case 'C': type = Character.TYPE; break;
case 'S': type = Short.TYPE; break;
case 'I': type = Integer.TYPE; break;
case 'J': type = Long.TYPE; break;
case 'F': type = Float.TYPE; break;
case 'D': type = Double.TYPE; break;
case 'L':
case '[': type = Object.class; break;
default: throw new IllegalArgumentException("illegal signature");
}
type = switch (signature.charAt(0)) {
case 'Z' -> Boolean.TYPE;
case 'B' -> Byte.TYPE;
case 'C' -> Character.TYPE;
case 'S' -> Short.TYPE;
case 'I' -> Integer.TYPE;
case 'J' -> Long.TYPE;
case 'F' -> Float.TYPE;
case 'D' -> Double.TYPE;
case 'L', '[' -> Object.class;
default -> throw new IllegalArgumentException("illegal signature");
};
}
/**