-
Enhancement
-
Resolution: Fixed
-
P3
-
19
-
b12
The impl spec of java.time.ZoneId states that ZoneId has two implementations:
"One implementation models region-based IDs, the other is {@code ZoneOffset} modelling offset-based IDs."
The ZoneId constructor has this check to ensure no other subclass can extend it:
ZoneId() {
if (getClass() != ZoneOffset.class && getClass() != ZoneRegion.class) {
throw new AssertionError("Invalid subclass");
}
}
ZoneId can be made a sealed abstract class that permits ZoneOffset and ZoneRegion to extend. The test in the constructor would no longer be needed.
"One implementation models region-based IDs, the other is {@code ZoneOffset} modelling offset-based IDs."
The ZoneId constructor has this check to ensure no other subclass can extend it:
ZoneId() {
if (getClass() != ZoneOffset.class && getClass() != ZoneRegion.class) {
throw new AssertionError("Invalid subclass");
}
}
ZoneId can be made a sealed abstract class that permits ZoneOffset and ZoneRegion to extend. The test in the constructor would no longer be needed.
- csr for
-
JDK-8282375 java.time.ZoneId should be a sealed abstract class
-
- Closed
-
- relates to
-
JDK-8282536 java.net.InetAddress should be a sealed class
-
- Resolved
-
-
JDK-8282572 EnumSet should be a sealed class
-
- Resolved
-
-
JDK-8283414 Update java.base to use sealed classes (umbrella)
-
- Closed
-
(1 links to)