Skip to content

Commit 6c12ecc

Browse files
author
duke
committedFeb 28, 2022
Automatic merge of jdk:master into master
2 parents f752286 + 0ae3d1d commit 6c12ecc

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed
 

‎src/java.base/share/classes/java/time/ZoneId.java

+6-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -169,14 +169,14 @@
169169
* The {@code equals} method should be used for comparisons.
170170
*
171171
* @implSpec
172-
* This abstract class has two implementations, both of which are immutable and thread-safe.
173-
* One implementation models region-based IDs, the other is {@code ZoneOffset} modelling
174-
* offset-based IDs. This difference is visible in serialization.
172+
* This abstract sealed class permits two implementations, both of which are immutable and
173+
* thread-safe. One implementation models region-based IDs, the other is {@code ZoneOffset}
174+
* modelling offset-based IDs. This difference is visible in serialization.
175175
*
176176
* @since 1.8
177177
*/
178178
@jdk.internal.ValueBased
179-
public abstract class ZoneId implements Serializable {
179+
public abstract sealed class ZoneId implements Serializable permits ZoneOffset, ZoneRegion {
180180

181181
/**
182182
* A map of zone overrides to enable the short time-zone names to be used.
@@ -471,11 +471,7 @@ public static ZoneId from(TemporalAccessor temporal) {
471471
/**
472472
* Constructor only accessible within the package.
473473
*/
474-
ZoneId() {
475-
if (getClass() != ZoneOffset.class && getClass() != ZoneRegion.class) {
476-
throw new AssertionError("Invalid subclass");
477-
}
478-
}
474+
ZoneId() {}
479475

480476
//-----------------------------------------------------------------------
481477
/**

0 commit comments

Comments
 (0)
Please sign in to comment.