62 package java.time.zone; |
62 package java.time.zone; |
63 |
63 |
64 import java.io.DataInput; |
64 import java.io.DataInput; |
65 import java.io.DataOutput; |
65 import java.io.DataOutput; |
66 import java.io.IOException; |
66 import java.io.IOException; |
|
67 import java.io.InvalidObjectException; |
67 import java.io.Serializable; |
68 import java.io.Serializable; |
68 import java.time.Duration; |
69 import java.time.Duration; |
69 import java.time.Instant; |
70 import java.time.Instant; |
70 import java.time.LocalDateTime; |
71 import java.time.LocalDateTime; |
71 import java.time.ZoneOffset; |
72 import java.time.ZoneOffset; |
168 this.offsetAfter = offsetAfter; |
169 this.offsetAfter = offsetAfter; |
169 } |
170 } |
170 |
171 |
171 //----------------------------------------------------------------------- |
172 //----------------------------------------------------------------------- |
172 /** |
173 /** |
173 * Uses a serialization delegate. |
174 * Defend against malicious streams. |
174 * |
175 * @return never |
|
176 * @throws InvalidObjectException always |
|
177 */ |
|
178 private Object readResolve() throws InvalidObjectException { |
|
179 throw new InvalidObjectException("Deserialization via serialization delegate"); |
|
180 } |
|
181 |
|
182 /** |
|
183 * Writes the object using a |
|
184 * <a href="../../../serialized-form.html#java.time.zone.Ser">dedicated serialized form</a>. |
|
185 * @serialData |
|
186 * Refer to the serialized form of |
|
187 * <a href="../../../serialized-form.html#java.time.zone.ZoneRules">ZoneRules.writeReplace</a> |
|
188 * for the encoding of epoch seconds and offsets. |
|
189 * <pre style="font-size:1.0em">{@code |
|
190 * |
|
191 * out.writeByte(2); // identifies a ZoneOffsetTransition |
|
192 * out.writeEpochSec(toEpochSecond); |
|
193 * out.writeOffset(offsetBefore); |
|
194 * out.writeOfset(offsetAfter); |
|
195 * } |
|
196 * </pre> |
175 * @return the replacing object, not null |
197 * @return the replacing object, not null |
176 */ |
198 */ |
177 private Object writeReplace() { |
199 private Object writeReplace() { |
178 return new Ser(Ser.ZOT, this); |
200 return new Ser(Ser.ZOT, this); |
179 } |
201 } |