Summary
Change java.time.ZoneId
to a sealed abstract class.
Problem
This is a refactoring of the said class with a better construct, as the class' implementation specification has already been limiting the subclassing to two subclasses, i.e., ZoneOffset
and ZoneRegion
.
Solution
Add sealed
modifier to the class declaration, and permit ZoneOffset
and ZoneRegion
as the subclasses.
Specification
Change the declaration of the class from:
public abstract class ZoneId implements Serializable
to:
public abstract sealed class ZoneId implements Serializable permits ZoneOffset, ZoneRegion
Change the @implSpec
in the class description to:
* @implSpec
* This abstract sealed class permits two implementations, both of which are immutable and
* thread-safe. One implementation models region-based IDs, the other is {@code ZoneOffset}
* modelling offset-based IDs. This difference is visible in serialization.
- csr of
-
JDK-8282131 java.time.ZoneId should be a sealed abstract class
-
- Resolved
-