diff --git a/classlib/src/main/java/org/threeten/bp/Clock.java b/classlib/src/main/java/org/threeten/bp/Clock.java index 4e11ecfd0..8b1fa132a 100644 --- a/classlib/src/main/java/org/threeten/bp/Clock.java +++ b/classlib/src/main/java/org/threeten/bp/Clock.java @@ -398,7 +398,6 @@ public abstract class Clock { * {@link System#currentTimeMillis()}. */ static final class SystemClock extends Clock implements Serializable { - private static final long serialVersionUID = 6740630888130243051L; private final ZoneId zone; SystemClock(ZoneId zone) { @@ -446,7 +445,6 @@ public abstract class Clock { * This is typically used for testing. */ static final class FixedClock extends Clock implements Serializable { - private static final long serialVersionUID = 7430389292664866958L; private final Instant instant; private final ZoneId zone; @@ -496,7 +494,6 @@ public abstract class Clock { * Implementation of a clock that adds an offset to an underlying clock. */ static final class OffsetClock extends Clock implements Serializable { - private static final long serialVersionUID = 2007484719125426256L; private final Clock baseClock; private final Duration offset; @@ -546,7 +543,6 @@ public abstract class Clock { * Implementation of a clock that adds an offset to an underlying clock. */ static final class TickClock extends Clock implements Serializable { - private static final long serialVersionUID = 6504659149906368850L; private final Clock baseClock; private final long tickNanos; diff --git a/classlib/src/main/java/org/threeten/bp/DateTimeException.java b/classlib/src/main/java/org/threeten/bp/DateTimeException.java index 1bf860d54..1c02e9113 100644 --- a/classlib/src/main/java/org/threeten/bp/DateTimeException.java +++ b/classlib/src/main/java/org/threeten/bp/DateTimeException.java @@ -42,11 +42,6 @@ package org.threeten.bp; */ public class DateTimeException extends RuntimeException { - /** - * Serialization version. - */ - private static final long serialVersionUID = -1632418723876261839L; - /** * Constructs a new date-time exception with the specified message. * diff --git a/classlib/src/main/java/org/threeten/bp/Duration.java b/classlib/src/main/java/org/threeten/bp/Duration.java index 49808f261..1b91250d6 100644 --- a/classlib/src/main/java/org/threeten/bp/Duration.java +++ b/classlib/src/main/java/org/threeten/bp/Duration.java @@ -39,11 +39,6 @@ import static org.threeten.bp.temporal.ChronoUnit.DAYS; import static org.threeten.bp.temporal.ChronoUnit.NANOS; import static org.threeten.bp.temporal.ChronoUnit.SECONDS; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.io.InvalidObjectException; -import java.io.ObjectStreamException; import java.io.Serializable; import java.math.BigDecimal; import java.math.BigInteger; @@ -98,10 +93,6 @@ public final class Duration * Constant for a duration of zero. */ public static final Duration ZERO = new Duration(0, 0); - /** - * Serialization version. - */ - private static final long serialVersionUID = 3078945930695997490L; /** * Constant for nanos per second. */ @@ -1232,29 +1223,5 @@ public final class Duration return buf.toString(); } - //----------------------------------------------------------------------- - private Object writeReplace() { - return new Ser(Ser.DURATION_TYPE, this); - } - - /** - * Defend against malicious streams. - * @return never - * @throws InvalidObjectException always - */ - private Object readResolve() throws ObjectStreamException { - throw new InvalidObjectException("Deserialization via serialization delegate"); - } - - void writeExternal(DataOutput out) throws IOException { - out.writeLong(seconds); - out.writeInt(nanos); - } - - static Duration readExternal(DataInput in) throws IOException { - long seconds = in.readLong(); - int nanos = in.readInt(); - return Duration.ofSeconds(seconds, nanos); - } } diff --git a/classlib/src/main/java/org/threeten/bp/Instant.java b/classlib/src/main/java/org/threeten/bp/Instant.java index 99e3da90c..d67fc1410 100644 --- a/classlib/src/main/java/org/threeten/bp/Instant.java +++ b/classlib/src/main/java/org/threeten/bp/Instant.java @@ -41,11 +41,6 @@ import static org.threeten.bp.temporal.ChronoField.NANO_OF_SECOND; import static org.threeten.bp.temporal.ChronoUnit.DAYS; import static org.threeten.bp.temporal.ChronoUnit.NANOS; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.io.InvalidObjectException; -import java.io.ObjectStreamException; import java.io.Serializable; import java.util.Objects; @@ -201,10 +196,6 @@ public final class Instant } }; - /** - * Serialization version. - */ - private static final long serialVersionUID = -665713676816604388L; /** * Constant for nanos per second. */ @@ -1160,30 +1151,4 @@ public final class Instant public String toString() { return DateTimeFormatter.ISO_INSTANT.format(this); } - - //----------------------------------------------------------------------- - private Object writeReplace() { - return new Ser(Ser.INSTANT_TYPE, this); - } - - /** - * Defend against malicious streams. - * @return never - * @throws InvalidObjectException always - */ - private Object readResolve() throws ObjectStreamException { - throw new InvalidObjectException("Deserialization via serialization delegate"); - } - - void writeExternal(DataOutput out) throws IOException { - out.writeLong(seconds); - out.writeInt(nanos); - } - - static Instant readExternal(DataInput in) throws IOException { - long seconds = in.readLong(); - int nanos = in.readInt(); - return Instant.ofEpochSecond(seconds, nanos); - } - } diff --git a/classlib/src/main/java/org/threeten/bp/LocalDate.java b/classlib/src/main/java/org/threeten/bp/LocalDate.java index 27d36886b..7139b175d 100644 --- a/classlib/src/main/java/org/threeten/bp/LocalDate.java +++ b/classlib/src/main/java/org/threeten/bp/LocalDate.java @@ -44,11 +44,6 @@ import static org.threeten.bp.temporal.ChronoField.MONTH_OF_YEAR; import static org.threeten.bp.temporal.ChronoField.PROLEPTIC_MONTH; import static org.threeten.bp.temporal.ChronoField.YEAR; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.io.InvalidObjectException; -import java.io.ObjectStreamException; import java.io.Serializable; import java.util.Objects; @@ -113,10 +108,6 @@ public final class LocalDate */ public static final LocalDate MAX = LocalDate.of(Year.MAX_VALUE, 12, 31); - /** - * Serialization version. - */ - private static final long serialVersionUID = 2942565459149668126L; /** * The number of days in a 400 year cycle. */ @@ -1850,32 +1841,4 @@ public final class LocalDate public String format(DateTimeFormatter formatter) { return super.format(formatter); } - - //----------------------------------------------------------------------- - private Object writeReplace() { - return new Ser(Ser.LOCAL_DATE_TYPE, this); - } - - /** - * Defend against malicious streams. - * @return never - * @throws InvalidObjectException always - */ - private Object readResolve() throws ObjectStreamException { - throw new InvalidObjectException("Deserialization via serialization delegate"); - } - - void writeExternal(DataOutput out) throws IOException { - out.writeInt(year); - out.writeByte(month); - out.writeByte(day); - } - - static LocalDate readExternal(DataInput in) throws IOException { - int year = in.readInt(); - int month = in.readByte(); - int dayOfMonth = in.readByte(); - return LocalDate.of(year, month, dayOfMonth); - } - } diff --git a/classlib/src/main/java/org/threeten/bp/LocalDateTime.java b/classlib/src/main/java/org/threeten/bp/LocalDateTime.java index e3dcb8bdc..1cf27184e 100644 --- a/classlib/src/main/java/org/threeten/bp/LocalDateTime.java +++ b/classlib/src/main/java/org/threeten/bp/LocalDateTime.java @@ -41,11 +41,6 @@ import static org.threeten.bp.LocalTime.NANOS_PER_MINUTE; import static org.threeten.bp.LocalTime.NANOS_PER_SECOND; import static org.threeten.bp.LocalTime.SECONDS_PER_DAY; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.io.InvalidObjectException; -import java.io.ObjectStreamException; import java.io.Serializable; import java.util.Objects; @@ -1814,30 +1809,4 @@ public final class LocalDateTime public String format(DateTimeFormatter formatter) { return super.format(formatter); } - - //----------------------------------------------------------------------- - private Object writeReplace() { - return new Ser(Ser.LOCAL_DATE_TIME_TYPE, this); - } - - /** - * Defend against malicious streams. - * @return never - * @throws InvalidObjectException always - */ - private Object readResolve() throws ObjectStreamException { - throw new InvalidObjectException("Deserialization via serialization delegate"); - } - - void writeExternal(DataOutput out) throws IOException { - date.writeExternal(out); - time.writeExternal(out); - } - - static LocalDateTime readExternal(DataInput in) throws IOException { - LocalDate date = LocalDate.readExternal(in); - LocalTime time = LocalTime.readExternal(in); - return LocalDateTime.of(date, time); - } - } diff --git a/classlib/src/main/java/org/threeten/bp/LocalTime.java b/classlib/src/main/java/org/threeten/bp/LocalTime.java index ff4adb76d..1bb7c6163 100644 --- a/classlib/src/main/java/org/threeten/bp/LocalTime.java +++ b/classlib/src/main/java/org/threeten/bp/LocalTime.java @@ -40,11 +40,6 @@ import static org.threeten.bp.temporal.ChronoField.SECOND_OF_DAY; import static org.threeten.bp.temporal.ChronoField.SECOND_OF_MINUTE; import static org.threeten.bp.temporal.ChronoUnit.NANOS; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.io.InvalidObjectException; -import java.io.ObjectStreamException; import java.io.Serializable; import java.util.Objects; @@ -177,11 +172,6 @@ public final class LocalTime */ static final long NANOS_PER_DAY = NANOS_PER_HOUR * HOURS_PER_DAY; - /** - * Serialization version. - */ - private static final long serialVersionUID = 6414437269572265201L; - /** * The hour. */ @@ -1503,64 +1493,4 @@ public final class LocalTime Objects.requireNonNull(formatter, "formatter"); return formatter.format(this); } - - //----------------------------------------------------------------------- - private Object writeReplace() { - return new Ser(Ser.LOCAL_TIME_TYPE, this); - } - - /** - * Defend against malicious streams. - * @return never - * @throws InvalidObjectException always - */ - private Object readResolve() throws ObjectStreamException { - throw new InvalidObjectException("Deserialization via serialization delegate"); - } - - void writeExternal(DataOutput out) throws IOException { - if (nano == 0) { - if (second == 0) { - if (minute == 0) { - out.writeByte(~hour); - } else { - out.writeByte(hour); - out.writeByte(~minute); - } - } else { - out.writeByte(hour); - out.writeByte(minute); - out.writeByte(~second); - } - } else { - out.writeByte(hour); - out.writeByte(minute); - out.writeByte(second); - out.writeInt(nano); - } - } - - static LocalTime readExternal(DataInput in) throws IOException { - int hour = in.readByte(); - int minute = 0; - int second = 0; - int nano = 0; - if (hour < 0) { - hour = ~hour; - } else { - minute = in.readByte(); - if (minute < 0) { - minute = ~minute; - } else { - second = in.readByte(); - if (second < 0) { - second = ~second; - } else { - nano = in.readInt(); - } - } - } - return LocalTime.of(hour, minute, second, nano); - } - } diff --git a/classlib/src/main/java/org/threeten/bp/MonthDay.java b/classlib/src/main/java/org/threeten/bp/MonthDay.java index 28ee83192..93ce92ced 100644 --- a/classlib/src/main/java/org/threeten/bp/MonthDay.java +++ b/classlib/src/main/java/org/threeten/bp/MonthDay.java @@ -34,11 +34,6 @@ package org.threeten.bp; import static org.threeten.bp.temporal.ChronoField.DAY_OF_MONTH; import static org.threeten.bp.temporal.ChronoField.MONTH_OF_YEAR; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.io.InvalidObjectException; -import java.io.ObjectStreamException; import java.io.Serializable; import java.util.Objects; @@ -702,30 +697,4 @@ public final class MonthDay Objects.requireNonNull(formatter, "formatter"); return formatter.format(this); } - - //----------------------------------------------------------------------- - private Object writeReplace() { - return new Ser(Ser.MONTH_DAY_TYPE, this); - } - - /** - * Defend against malicious streams. - * @return never - * @throws InvalidObjectException always - */ - private Object readResolve() throws ObjectStreamException { - throw new InvalidObjectException("Deserialization via serialization delegate"); - } - - void writeExternal(DataOutput out) throws IOException { - out.writeByte(month); - out.writeByte(day); - } - - static MonthDay readExternal(DataInput in) throws IOException { - byte month = in.readByte(); - byte day = in.readByte(); - return MonthDay.of(month, day); - } - } diff --git a/classlib/src/main/java/org/threeten/bp/OffsetDateTime.java b/classlib/src/main/java/org/threeten/bp/OffsetDateTime.java index f6f6cdfc9..8776d1777 100644 --- a/classlib/src/main/java/org/threeten/bp/OffsetDateTime.java +++ b/classlib/src/main/java/org/threeten/bp/OffsetDateTime.java @@ -37,11 +37,6 @@ import static org.threeten.bp.temporal.ChronoField.NANO_OF_DAY; import static org.threeten.bp.temporal.ChronoField.OFFSET_SECONDS; import static org.threeten.bp.temporal.ChronoUnit.NANOS; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.io.InvalidObjectException; -import java.io.ObjectStreamException; import java.io.Serializable; import java.util.Comparator; import java.util.Objects; @@ -134,11 +129,6 @@ public final class OffsetDateTime private static final Comparator INSTANT_COMPARATOR = Comparator.comparingLong(OffsetDateTime::toEpochSecond).thenComparingInt(OffsetDateTime::getNano); - /** - * Serialization version. - */ - private static final long serialVersionUID = 2287754244819255394L; - /** * The local date-time. */ @@ -1780,30 +1770,4 @@ public final class OffsetDateTime Objects.requireNonNull(formatter, "formatter"); return formatter.format(this); } - - //----------------------------------------------------------------------- - private Object writeReplace() { - return new Ser(Ser.OFFSET_DATE_TIME_TYPE, this); - } - - /** - * Defend against malicious streams. - * @return never - * @throws InvalidObjectException always - */ - private Object readResolve() throws ObjectStreamException { - throw new InvalidObjectException("Deserialization via serialization delegate"); - } - - void writeExternal(DataOutput out) throws IOException { - dateTime.writeExternal(out); - offset.writeExternal(out); - } - - static OffsetDateTime readExternal(DataInput in) throws IOException { - LocalDateTime dateTime = LocalDateTime.readExternal(in); - ZoneOffset offset = ZoneOffset.readExternal(in); - return OffsetDateTime.of(dateTime, offset); - } - } diff --git a/classlib/src/main/java/org/threeten/bp/OffsetTime.java b/classlib/src/main/java/org/threeten/bp/OffsetTime.java index a953759a1..9f3f86c6f 100644 --- a/classlib/src/main/java/org/threeten/bp/OffsetTime.java +++ b/classlib/src/main/java/org/threeten/bp/OffsetTime.java @@ -39,11 +39,6 @@ import static org.threeten.bp.temporal.ChronoField.NANO_OF_DAY; import static org.threeten.bp.temporal.ChronoField.OFFSET_SECONDS; import static org.threeten.bp.temporal.ChronoUnit.NANOS; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.io.InvalidObjectException; -import java.io.ObjectStreamException; import java.io.Serializable; import java.util.Objects; @@ -106,11 +101,6 @@ public final class OffsetTime } }; - /** - * Serialization version. - */ - private static final long serialVersionUID = 7264499704384272492L; - /** * The local date-time. */ @@ -1285,30 +1275,4 @@ public final class OffsetTime Objects.requireNonNull(formatter, "formatter"); return formatter.format(this); } - - // ----------------------------------------------------------------------- - private Object writeReplace() { - return new Ser(Ser.OFFSET_TIME_TYPE, this); - } - - /** - * Defend against malicious streams. - * @return never - * @throws InvalidObjectException always - */ - private Object readResolve() throws ObjectStreamException { - throw new InvalidObjectException("Deserialization via serialization delegate"); - } - - void writeExternal(DataOutput out) throws IOException { - time.writeExternal(out); - offset.writeExternal(out); - } - - static OffsetTime readExternal(DataInput in) throws IOException { - LocalTime time = LocalTime.readExternal(in); - ZoneOffset offset = ZoneOffset.readExternal(in); - return OffsetTime.of(time, offset); - } - } diff --git a/classlib/src/main/java/org/threeten/bp/Period.java b/classlib/src/main/java/org/threeten/bp/Period.java index cb40f1b6c..7621ebd86 100644 --- a/classlib/src/main/java/org/threeten/bp/Period.java +++ b/classlib/src/main/java/org/threeten/bp/Period.java @@ -97,10 +97,6 @@ public final class Period * A constant for a period of zero. */ public static final Period ZERO = new Period(0, 0, 0); - /** - * Serialization version. - */ - private static final long serialVersionUID = -8290556941213247973L; /** * The pattern for parsing. */ diff --git a/classlib/src/main/java/org/threeten/bp/Ser.java b/classlib/src/main/java/org/threeten/bp/Ser.java deleted file mode 100644 index 5a2179e54..000000000 --- a/classlib/src/main/java/org/threeten/bp/Ser.java +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * * Neither the name of JSR-310 nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package org.threeten.bp; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.Externalizable; -import java.io.IOException; -import java.io.InvalidClassException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.io.StreamCorruptedException; - -/** - * The shared serialization delegate for this package. - * - *

Implementation notes

- * This class wraps the object being serialized, and takes a byte representing the type of the class to - * be serialized. This byte can also be used for versioning the serialization format. In this case another - * byte flag would be used in order to specify an alternative version of the type format. - * For example {@code LOCAL_DATE_TYPE_VERSION_2 = 21}. - *

- * In order to serialise the object it writes its byte and then calls back to the appropriate class where - * the serialisation is performed. In order to deserialise the object it read in the type byte, switching - * in order to select which class to call back into. - *

- * The serialisation format is determined on a per class basis. In the case of field based classes each - * of the fields is written out with an appropriate size format in descending order of the field's size. For - * example in the case of {@link LocalDate} year is written before month. Composite classes, such as - * {@link LocalDateTime} are serialised as one object. - *

- * This class is mutable and should be created once per serialization. - * - * @serial include - */ -final class Ser implements Externalizable { - - /** - * Serialization version. - */ - private static final long serialVersionUID = -7683839454370182990L; - - static final byte DURATION_TYPE = 1; - static final byte INSTANT_TYPE = 2; - static final byte LOCAL_DATE_TYPE = 3; - static final byte LOCAL_DATE_TIME_TYPE = 4; - static final byte LOCAL_TIME_TYPE = 5; - static final byte ZONED_DATE_TIME_TYPE = 6; - static final byte ZONE_REGION_TYPE = 7; - static final byte ZONE_OFFSET_TYPE = 8; - - static final byte MONTH_DAY_TYPE = 64; - static final byte OFFSET_TIME_TYPE = 66; - static final byte YEAR_TYPE = 67; - static final byte YEAR_MONTH_TYPE = 68; - static final byte OFFSET_DATE_TIME_TYPE = 69; - - /** The type being serialized. */ - private byte type; - /** The object being serialized. */ - private Object object; - - /** - * Constructor for deserialization. - */ - public Ser() { - } - - /** - * Creates an instance for serialization. - * - * @param type the type - * @param object the object - */ - Ser(byte type, Object object) { - this.type = type; - this.object = object; - } - - //----------------------------------------------------------------------- - /** - * Implements the {@code Externalizable} interface to write the object. - * - * @param out the data stream to write to, not null - */ - public void writeExternal(ObjectOutput out) throws IOException { - writeInternal(type, object, out); - } - - static void writeInternal(byte type, Object object, DataOutput out) throws IOException { - out.writeByte(type); - switch (type) { - case DURATION_TYPE: - ((Duration) object).writeExternal(out); - break; - case INSTANT_TYPE: - ((Instant) object).writeExternal(out); - break; - case LOCAL_DATE_TYPE: - ((LocalDate) object).writeExternal(out); - break; - case LOCAL_DATE_TIME_TYPE: - ((LocalDateTime) object).writeExternal(out); - break; - case LOCAL_TIME_TYPE: - ((LocalTime) object).writeExternal(out); - break; - case MONTH_DAY_TYPE: - ((MonthDay) object).writeExternal(out); - break; - case OFFSET_DATE_TIME_TYPE: - ((OffsetDateTime) object).writeExternal(out); - break; - case OFFSET_TIME_TYPE: - ((OffsetTime) object).writeExternal(out); - break; - case YEAR_MONTH_TYPE: - ((YearMonth) object).writeExternal(out); - break; - case YEAR_TYPE: - ((Year) object).writeExternal(out); - break; - case ZONE_REGION_TYPE: - ((ZoneRegion) object).writeExternal(out); - break; - case ZONE_OFFSET_TYPE: - ((ZoneOffset) object).writeExternal(out); - break; - case ZONED_DATE_TIME_TYPE: - ((ZonedDateTime) object).writeExternal(out); - break; - default: - throw new InvalidClassException("Unknown serialized type"); - } - } - - //----------------------------------------------------------------------- - /** - * Implements the {@code Externalizable} interface to read the object. - * - * @param in the data to read, not null - */ - public void readExternal(ObjectInput in) throws IOException { - type = in.readByte(); - object = readInternal(type, in); - } - - static Object read(DataInput in) throws IOException { - byte type = in.readByte(); - return readInternal(type, in); - } - - private static Object readInternal(byte type, DataInput in) throws IOException { - switch (type) { - case DURATION_TYPE: return Duration.readExternal(in); - case INSTANT_TYPE: return Instant.readExternal(in); - case LOCAL_DATE_TYPE: return LocalDate.readExternal(in); - case LOCAL_DATE_TIME_TYPE: return LocalDateTime.readExternal(in); - case LOCAL_TIME_TYPE: return LocalTime.readExternal(in); - case MONTH_DAY_TYPE: return MonthDay.readExternal(in); - case OFFSET_DATE_TIME_TYPE: return OffsetDateTime.readExternal(in); - case OFFSET_TIME_TYPE: return OffsetTime.readExternal(in); - case YEAR_TYPE: return Year.readExternal(in); - case YEAR_MONTH_TYPE: return YearMonth.readExternal(in); - case ZONED_DATE_TIME_TYPE: return ZonedDateTime.readExternal(in); - case ZONE_OFFSET_TYPE: return ZoneOffset.readExternal(in); - case ZONE_REGION_TYPE: return ZoneRegion.readExternal(in); - default: - throw new StreamCorruptedException("Unknown serialized type"); - } - } - - /** - * Returns the object that will replace this one. - * - * @return the read object, should never be null - */ - private Object readResolve() { - return object; - } - -} diff --git a/classlib/src/main/java/org/threeten/bp/Year.java b/classlib/src/main/java/org/threeten/bp/Year.java index 8e7efe52e..acf43f352 100644 --- a/classlib/src/main/java/org/threeten/bp/Year.java +++ b/classlib/src/main/java/org/threeten/bp/Year.java @@ -40,11 +40,6 @@ import static org.threeten.bp.temporal.ChronoUnit.ERAS; import static org.threeten.bp.temporal.ChronoUnit.MILLENNIA; import static org.threeten.bp.temporal.ChronoUnit.YEARS; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.io.InvalidObjectException; -import java.io.ObjectStreamException; import java.io.Serializable; import java.util.Objects; @@ -107,10 +102,6 @@ public final class Year */ public static final int MAX_VALUE = 999999999; - /** - * Serialization version. - */ - private static final long serialVersionUID = -23038383694477807L; /** * Parser. */ @@ -947,27 +938,4 @@ public final class Year Objects.requireNonNull(formatter, "formatter"); return formatter.format(this); } - - //----------------------------------------------------------------------- - private Object writeReplace() { - return new Ser(Ser.YEAR_TYPE, this); - } - - /** - * Defend against malicious streams. - * @return never - * @throws InvalidObjectException always - */ - private Object readResolve() throws ObjectStreamException { - throw new InvalidObjectException("Deserialization via serialization delegate"); - } - - void writeExternal(DataOutput out) throws IOException { - out.writeInt(year); - } - - static Year readExternal(DataInput in) throws IOException { - return Year.of(in.readInt()); - } - } diff --git a/classlib/src/main/java/org/threeten/bp/YearMonth.java b/classlib/src/main/java/org/threeten/bp/YearMonth.java index f8375330a..c5ce21d4f 100644 --- a/classlib/src/main/java/org/threeten/bp/YearMonth.java +++ b/classlib/src/main/java/org/threeten/bp/YearMonth.java @@ -43,11 +43,6 @@ import static org.threeten.bp.temporal.ChronoUnit.MILLENNIA; import static org.threeten.bp.temporal.ChronoUnit.MONTHS; import static org.threeten.bp.temporal.ChronoUnit.YEARS; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.io.InvalidObjectException; -import java.io.ObjectStreamException; import java.io.Serializable; import java.util.Objects; @@ -94,10 +89,6 @@ import org.threeten.bp.temporal.ValueRange; public final class YearMonth implements Temporal, TemporalAdjuster, Comparable, Serializable, TemporalAccessor { - /** - * Serialization version. - */ - private static final long serialVersionUID = 4183400860270640070L; /** * Parser. */ @@ -1068,30 +1059,4 @@ public final class YearMonth Objects.requireNonNull(formatter, "formatter"); return formatter.format(this); } - - //----------------------------------------------------------------------- - private Object writeReplace() { - return new Ser(Ser.YEAR_MONTH_TYPE, this); - } - - /** - * Defend against malicious streams. - * @return never - * @throws InvalidObjectException always - */ - private Object readResolve() throws ObjectStreamException { - throw new InvalidObjectException("Deserialization via serialization delegate"); - } - - void writeExternal(DataOutput out) throws IOException { - out.writeInt(year); - out.writeByte(month); - } - - static YearMonth readExternal(DataInput in) throws IOException { - int year = in.readInt(); - byte month = in.readByte(); - return YearMonth.of(year, month); - } - } diff --git a/classlib/src/main/java/org/threeten/bp/ZoneId.java b/classlib/src/main/java/org/threeten/bp/ZoneId.java index ec4f1ab13..c19fb1cea 100644 --- a/classlib/src/main/java/org/threeten/bp/ZoneId.java +++ b/classlib/src/main/java/org/threeten/bp/ZoneId.java @@ -31,8 +31,6 @@ */ package org.threeten.bp; -import java.io.DataOutput; -import java.io.IOException; import java.io.Serializable; import java.util.Collections; import java.util.HashMap; @@ -223,10 +221,6 @@ public abstract class ZoneId implements Serializable { base.put("HST", "-10:00"); SHORT_IDS = Collections.unmodifiableMap(base); } - /** - * Serialization version. - */ - private static final long serialVersionUID = 8352817235686L; //----------------------------------------------------------------------- /** @@ -558,7 +552,4 @@ public abstract class ZoneId implements Serializable { return getId(); } - //----------------------------------------------------------------------- - abstract void write(DataOutput out) throws IOException; - } diff --git a/classlib/src/main/java/org/threeten/bp/ZoneOffset.java b/classlib/src/main/java/org/threeten/bp/ZoneOffset.java index 3dce38b7e..419035d81 100644 --- a/classlib/src/main/java/org/threeten/bp/ZoneOffset.java +++ b/classlib/src/main/java/org/threeten/bp/ZoneOffset.java @@ -33,11 +33,6 @@ package org.threeten.bp; import static org.threeten.bp.temporal.ChronoField.OFFSET_SECONDS; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.io.InvalidObjectException; -import java.io.ObjectStreamException; import java.io.Serializable; import java.util.HashMap; import java.util.Map; @@ -111,10 +106,6 @@ public final class ZoneOffset * The abs maximum seconds. */ private static final int MAX_SECONDS = 18 * SECONDS_PER_HOUR; - /** - * Serialization version. - */ - private static final long serialVersionUID = 2357656521762053153L; /** * The time-zone offset for UTC, with an ID of 'Z'. @@ -713,39 +704,4 @@ public final class ZoneOffset public String toString() { return id; } - - // ----------------------------------------------------------------------- - private Object writeReplace() { - return new Ser(Ser.ZONE_OFFSET_TYPE, this); - } - - /** - * Defend against malicious streams. - * @return never - * @throws InvalidObjectException always - */ - private Object readResolve() throws ObjectStreamException { - throw new InvalidObjectException("Deserialization via serialization delegate"); - } - - @Override - void write(DataOutput out) throws IOException { - out.writeByte(Ser.ZONE_OFFSET_TYPE); - writeExternal(out); - } - - void writeExternal(DataOutput out) throws IOException { - final int offsetSecs = totalSeconds; - int offsetByte = offsetSecs % 900 == 0 ? offsetSecs / 900 : 127; // compress to -72 to +72 - out.writeByte(offsetByte); - if (offsetByte == 127) { - out.writeInt(offsetSecs); - } - } - - static ZoneOffset readExternal(DataInput in) throws IOException { - int offsetByte = in.readByte(); - return (offsetByte == 127 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds(offsetByte * 900)); - } - } diff --git a/classlib/src/main/java/org/threeten/bp/ZoneRegion.java b/classlib/src/main/java/org/threeten/bp/ZoneRegion.java index bcd72987d..9bc77691a 100644 --- a/classlib/src/main/java/org/threeten/bp/ZoneRegion.java +++ b/classlib/src/main/java/org/threeten/bp/ZoneRegion.java @@ -31,11 +31,6 @@ */ package org.threeten.bp; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.io.InvalidObjectException; -import java.io.ObjectStreamException; import java.io.Serializable; import java.util.Objects; @@ -64,10 +59,6 @@ import org.threeten.bp.zone.ZoneRulesProvider; */ final class ZoneRegion extends ZoneId implements Serializable { - /** - * Serialization version. - */ - private static final long serialVersionUID = 8386373296231747096L; /** * The regex pattern for region IDs. */ @@ -176,34 +167,4 @@ final class ZoneRegion extends ZoneId implements Serializable { // that the provider was added after the ZoneId was created return (rules != null ? rules : ZoneRulesProvider.getRules(id, false)); } - - //----------------------------------------------------------------------- - private Object writeReplace() { - return new Ser(Ser.ZONE_REGION_TYPE, this); - } - - /** - * Defend against malicious streams. - * @return never - * @throws InvalidObjectException always - */ - private Object readResolve() throws ObjectStreamException { - throw new InvalidObjectException("Deserialization via serialization delegate"); - } - - @Override - void write(DataOutput out) throws IOException { - out.writeByte(Ser.ZONE_REGION_TYPE); - writeExternal(out); - } - - void writeExternal(DataOutput out) throws IOException { - out.writeUTF(id); - } - - static ZoneId readExternal(DataInput in) throws IOException { - String id = in.readUTF(); - return ofLenient(id); - } - } diff --git a/classlib/src/main/java/org/threeten/bp/ZonedDateTime.java b/classlib/src/main/java/org/threeten/bp/ZonedDateTime.java index 63932084a..7f4bf37c2 100644 --- a/classlib/src/main/java/org/threeten/bp/ZonedDateTime.java +++ b/classlib/src/main/java/org/threeten/bp/ZonedDateTime.java @@ -35,11 +35,6 @@ import static org.threeten.bp.temporal.ChronoField.INSTANT_SECONDS; import static org.threeten.bp.temporal.ChronoField.NANO_OF_SECOND; import static org.threeten.bp.temporal.ChronoField.OFFSET_SECONDS; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.io.InvalidObjectException; -import java.io.ObjectStreamException; import java.io.Serializable; import java.util.List; import java.util.Objects; @@ -2081,31 +2076,5 @@ public final class ZonedDateTime return super.format(formatter); } - //----------------------------------------------------------------------- - private Object writeReplace() { - return new Ser(Ser.ZONED_DATE_TIME_TYPE, this); - } - - /** - * Defend against malicious streams. - * @return never - * @throws InvalidObjectException always - */ - private Object readResolve() throws ObjectStreamException { - throw new InvalidObjectException("Deserialization via serialization delegate"); - } - - void writeExternal(DataOutput out) throws IOException { - dateTime.writeExternal(out); - offset.writeExternal(out); - zone.write(out); - } - - static ZonedDateTime readExternal(DataInput in) throws IOException { - LocalDateTime dateTime = LocalDateTime.readExternal(in); - ZoneOffset offset = ZoneOffset.readExternal(in); - ZoneId zone = (ZoneId) Ser.read(in); - return ZonedDateTime.ofLenient(dateTime, offset, zone); - } } diff --git a/classlib/src/main/java/org/threeten/bp/chrono/ChronoDateImpl.java b/classlib/src/main/java/org/threeten/bp/chrono/ChronoDateImpl.java index da0616166..3c5e0df10 100644 --- a/classlib/src/main/java/org/threeten/bp/chrono/ChronoDateImpl.java +++ b/classlib/src/main/java/org/threeten/bp/chrono/ChronoDateImpl.java @@ -112,11 +112,6 @@ abstract class ChronoDateImpl extends ChronoLocalDate implements Temporal, TemporalAdjuster, Serializable { - /** - * Serialization version. - */ - private static final long serialVersionUID = 6282433883239719096L; - /** * Creates an instance. */ diff --git a/classlib/src/main/java/org/threeten/bp/chrono/ChronoLocalDateTimeImpl.java b/classlib/src/main/java/org/threeten/bp/chrono/ChronoLocalDateTimeImpl.java index 40f741663..64cfb887b 100644 --- a/classlib/src/main/java/org/threeten/bp/chrono/ChronoLocalDateTimeImpl.java +++ b/classlib/src/main/java/org/threeten/bp/chrono/ChronoLocalDateTimeImpl.java @@ -33,9 +33,6 @@ package org.threeten.bp.chrono; import static org.threeten.bp.temporal.ChronoField.EPOCH_DAY; -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; import java.io.Serializable; import java.util.Objects; @@ -70,10 +67,6 @@ final class ChronoLocalDateTimeImpl extends ChronoLocalDateTime implements Temporal, TemporalAdjuster, Serializable { - /** - * Serialization version. - */ - private static final long serialVersionUID = 4556003607393004514L; /** * Hours per minute. */ @@ -348,20 +341,4 @@ final class ChronoLocalDateTimeImpl return unit.between(this, end); } - //----------------------------------------------------------------------- - private Object writeReplace() { - return new Ser(Ser.CHRONO_LOCALDATETIME_TYPE, this); - } - - void writeExternal(ObjectOutput out) throws IOException { - out.writeObject(date); - out.writeObject(time); - } - - static ChronoLocalDateTime readExternal(ObjectInput in) throws IOException, ClassNotFoundException { - ChronoLocalDate date = (ChronoLocalDate) in.readObject(); - LocalTime time = (LocalTime) in.readObject(); - return date.atTime(time); - } - } diff --git a/classlib/src/main/java/org/threeten/bp/chrono/ChronoPeriodImpl.java b/classlib/src/main/java/org/threeten/bp/chrono/ChronoPeriodImpl.java index 95817e87d..af41963bc 100644 --- a/classlib/src/main/java/org/threeten/bp/chrono/ChronoPeriodImpl.java +++ b/classlib/src/main/java/org/threeten/bp/chrono/ChronoPeriodImpl.java @@ -57,11 +57,6 @@ final class ChronoPeriodImpl extends ChronoPeriod implements Serializable { - /** - * Serialization version. - */ - private static final long serialVersionUID = 275618735781L; - private final Chronology chronology; private final int years; private final int months; diff --git a/classlib/src/main/java/org/threeten/bp/chrono/ChronoZonedDateTimeImpl.java b/classlib/src/main/java/org/threeten/bp/chrono/ChronoZonedDateTimeImpl.java index a2ec98c1f..5ebb7f442 100644 --- a/classlib/src/main/java/org/threeten/bp/chrono/ChronoZonedDateTimeImpl.java +++ b/classlib/src/main/java/org/threeten/bp/chrono/ChronoZonedDateTimeImpl.java @@ -33,11 +33,6 @@ package org.threeten.bp.chrono; import static org.threeten.bp.temporal.ChronoUnit.SECONDS; -import java.io.IOException; -import java.io.InvalidObjectException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.io.ObjectStreamException; import java.io.Serializable; import java.util.List; import java.util.Objects; @@ -74,11 +69,6 @@ final class ChronoZonedDateTimeImpl extends ChronoZonedDateTime implements Serializable { - /** - * Serialization version. - */ - private static final long serialVersionUID = -5261813987200935591L; - /** * The local date-time. */ @@ -273,34 +263,6 @@ final class ChronoZonedDateTimeImpl return unit.between(this, end); } - //----------------------------------------------------------------------- - private Object writeReplace() { - return new Ser(Ser.CHRONO_ZONEDDATETIME_TYPE, this); - } - - /** - * Defend against malicious streams. - * @return never - * @throws InvalidObjectException always - */ - private Object readResolve() throws ObjectStreamException { - throw new InvalidObjectException("Deserialization via serialization delegate"); - } - - void writeExternal(ObjectOutput out) throws IOException { - out.writeObject(dateTime); - out.writeObject(offset); - out.writeObject(zone); - } - - static ChronoZonedDateTime readExternal(ObjectInput in) throws IOException, ClassNotFoundException { - ChronoLocalDateTime dateTime = (ChronoLocalDateTime) in.readObject(); - ZoneOffset offset = (ZoneOffset) in.readObject(); - ZoneId zone = (ZoneId) in.readObject(); - return dateTime.atZone(offset).withZoneSameLocal(zone); - // TODO: ZDT uses ofLenient() - } - //------------------------------------------------------------------------- @Override public boolean equals(Object obj) { diff --git a/classlib/src/main/java/org/threeten/bp/chrono/Chronology.java b/classlib/src/main/java/org/threeten/bp/chrono/Chronology.java index 5b8b4e8b9..743b88927 100644 --- a/classlib/src/main/java/org/threeten/bp/chrono/Chronology.java +++ b/classlib/src/main/java/org/threeten/bp/chrono/Chronology.java @@ -31,11 +31,6 @@ */ package org.threeten.bp.chrono; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.io.InvalidObjectException; -import java.io.ObjectStreamException; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -835,27 +830,4 @@ public abstract class Chronology implements Comparable { return getId(); } - //----------------------------------------------------------------------- - private Object writeReplace() { - return new Ser(Ser.CHRONO_TYPE, this); - } - - /** - * Defend against malicious streams. - * @return never - * @throws InvalidObjectException always - */ - private Object readResolve() throws ObjectStreamException { - throw new InvalidObjectException("Deserialization via serialization delegate"); - } - - void writeExternal(DataOutput out) throws IOException { - out.writeUTF(getId()); - } - - static Chronology readExternal(DataInput in) throws IOException { - String id = in.readUTF(); - return Chronology.of(id); - } - } diff --git a/classlib/src/main/java/org/threeten/bp/chrono/HijrahChronology.java b/classlib/src/main/java/org/threeten/bp/chrono/HijrahChronology.java index 9e40351b3..22e6230a8 100644 --- a/classlib/src/main/java/org/threeten/bp/chrono/HijrahChronology.java +++ b/classlib/src/main/java/org/threeten/bp/chrono/HijrahChronology.java @@ -176,10 +176,6 @@ public final class HijrahChronology extends Chronology implements Serializable { */ public static final HijrahChronology INSTANCE = new HijrahChronology(); - /** - * Serialization version. - */ - private static final long serialVersionUID = 3127340209035924785L; /** * Narrow names for eras. */ diff --git a/classlib/src/main/java/org/threeten/bp/chrono/HijrahDate.java b/classlib/src/main/java/org/threeten/bp/chrono/HijrahDate.java index 9f8a09f4a..90a5bd83c 100644 --- a/classlib/src/main/java/org/threeten/bp/chrono/HijrahDate.java +++ b/classlib/src/main/java/org/threeten/bp/chrono/HijrahDate.java @@ -35,13 +35,8 @@ import static org.threeten.bp.temporal.ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH; import static org.threeten.bp.temporal.ChronoField.ALIGNED_DAY_OF_WEEK_IN_YEAR; import static org.threeten.bp.temporal.ChronoField.ALIGNED_WEEK_OF_MONTH; import static org.threeten.bp.temporal.ChronoField.ALIGNED_WEEK_OF_YEAR; -import static org.threeten.bp.temporal.ChronoField.DAY_OF_MONTH; -import static org.threeten.bp.temporal.ChronoField.MONTH_OF_YEAR; -import static org.threeten.bp.temporal.ChronoField.YEAR; import java.io.BufferedReader; -import java.io.DataInput; -import java.io.DataOutput; import java.io.File; import java.io.FileInputStream; import java.io.IOException; @@ -115,11 +110,6 @@ public final class HijrahDate // this class is package-scoped so that future conversion to public // would not change serialization - /** - * Serialization version. - */ - private static final long serialVersionUID = -5207853542612002020L; - /** * The minimum valid year-of-era. */ @@ -604,15 +594,6 @@ public final class HijrahDate this.isLeapYear = isLeapYear(this.yearOfEra); } - /** - * Replaces the date instance from the stream with a valid one. - * - * @return the resolved date, never null - */ - private Object readResolve() { - return new HijrahDate(this.gregorianEpochDay); - } - //----------------------------------------------------------------------- @Override public HijrahChronology getChronology() { @@ -1756,23 +1737,4 @@ public final class HijrahDate return null; } } - //----------------------------------------------------------------------- - private Object writeReplace() { - return new Ser(Ser.HIJRAH_DATE_TYPE, this); - } - - void writeExternal(DataOutput out) throws IOException { - // HijrahChrono is implicit in the Hijrah_DATE_TYPE - out.writeInt(get(YEAR)); - out.writeByte(get(MONTH_OF_YEAR)); - out.writeByte(get(DAY_OF_MONTH)); - } - - static ChronoLocalDate readExternal(DataInput in) throws IOException { - int year = in.readInt(); - int month = in.readByte(); - int dayOfMonth = in.readByte(); - return HijrahChronology.INSTANCE.date(year, month, dayOfMonth); - } - } diff --git a/classlib/src/main/java/org/threeten/bp/chrono/HijrahEra.java b/classlib/src/main/java/org/threeten/bp/chrono/HijrahEra.java index 2387dbc8c..879095b42 100644 --- a/classlib/src/main/java/org/threeten/bp/chrono/HijrahEra.java +++ b/classlib/src/main/java/org/threeten/bp/chrono/HijrahEra.java @@ -33,9 +33,6 @@ package org.threeten.bp.chrono; import static org.threeten.bp.temporal.ChronoField.ERA; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; import java.util.Locale; import org.threeten.bp.DateTimeException; @@ -183,18 +180,4 @@ public enum HijrahEra implements Era { return (this == HijrahEra.AH ? yearOfEra : 1 - yearOfEra); } - //----------------------------------------------------------------------- - private Object writeReplace() { - return new Ser(Ser.HIJRAH_ERA_TYPE, this); - } - - void writeExternal(DataOutput out) throws IOException { - out.writeByte(this.getValue()); - } - - static HijrahEra readExternal(DataInput in) throws IOException { - byte eraValue = in.readByte(); - return HijrahEra.of(eraValue); - } - } diff --git a/classlib/src/main/java/org/threeten/bp/chrono/IsoChronology.java b/classlib/src/main/java/org/threeten/bp/chrono/IsoChronology.java index 84bdfcec8..b069195bd 100644 --- a/classlib/src/main/java/org/threeten/bp/chrono/IsoChronology.java +++ b/classlib/src/main/java/org/threeten/bp/chrono/IsoChronology.java @@ -103,11 +103,6 @@ public final class IsoChronology extends Chronology implements Serializable { */ public static final IsoChronology INSTANCE = new IsoChronology(); - /** - * Serialization version. - */ - private static final long serialVersionUID = -1440403870442975015L; - /** * Restricted constructor. */ diff --git a/classlib/src/main/java/org/threeten/bp/chrono/JapaneseChronology.java b/classlib/src/main/java/org/threeten/bp/chrono/JapaneseChronology.java index cba9d3c49..8eb2c2148 100644 --- a/classlib/src/main/java/org/threeten/bp/chrono/JapaneseChronology.java +++ b/classlib/src/main/java/org/threeten/bp/chrono/JapaneseChronology.java @@ -109,11 +109,6 @@ public final class JapaneseChronology extends Chronology implements Serializable */ public static final JapaneseChronology INSTANCE = new JapaneseChronology(); - /** - * Serialization version. - */ - private static final long serialVersionUID = 459996390165777884L; - /** * Narrow names for eras. */ diff --git a/classlib/src/main/java/org/threeten/bp/chrono/JapaneseDate.java b/classlib/src/main/java/org/threeten/bp/chrono/JapaneseDate.java index 11085fff4..1742a8215 100644 --- a/classlib/src/main/java/org/threeten/bp/chrono/JapaneseDate.java +++ b/classlib/src/main/java/org/threeten/bp/chrono/JapaneseDate.java @@ -31,14 +31,6 @@ */ package org.threeten.bp.chrono; -import static org.threeten.bp.temporal.ChronoField.DAY_OF_MONTH; -import static org.threeten.bp.temporal.ChronoField.MONTH_OF_YEAR; -import static org.threeten.bp.temporal.ChronoField.YEAR; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.io.ObjectInputStream; import java.io.Serializable; import java.util.Calendar; import java.util.Objects; @@ -85,10 +77,6 @@ public final class JapaneseDate extends ChronoDateImpl implements Serializable { - /** - * Serialization version. - */ - private static final long serialVersionUID = -305327627230580483L; /** * Minimum date. */ @@ -306,18 +294,6 @@ public final class JapaneseDate this.isoDate = isoDate; } - /** - * Reconstitutes this object from a stream. - * - * @param stream object input stream - */ - private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { - stream.defaultReadObject(); - this.era = JapaneseEra.from(isoDate); - int yearOffset = this.era.startDate().getYear() - 1; - this.yearOfEra = isoDate.getYear() - yearOffset; - } - //----------------------------------------------------------------------- @Override public JapaneseChronology getChronology() { @@ -583,25 +559,4 @@ public final class JapaneseDate public int hashCode() { return getChronology().getId().hashCode() ^ isoDate.hashCode(); } - - //----------------------------------------------------------------------- - private Object writeReplace() { - return new Ser(Ser.JAPANESE_DATE_TYPE, this); - } - - void writeExternal(DataOutput out) throws IOException { - // JapaneseChrono is implicit in the JAPANESE_DATE_TYPE - out.writeInt(get(YEAR)); - out.writeByte(get(MONTH_OF_YEAR)); - out.writeByte(get(DAY_OF_MONTH)); - } - - static ChronoLocalDate readExternal(DataInput in) throws IOException { - int year = in.readInt(); - int month = in.readByte(); - int dayOfMonth = in.readByte(); - return JapaneseChronology.INSTANCE.date(year, month, dayOfMonth); - } - - } diff --git a/classlib/src/main/java/org/threeten/bp/chrono/JapaneseEra.java b/classlib/src/main/java/org/threeten/bp/chrono/JapaneseEra.java index 7388ff817..cbb7f4e6f 100644 --- a/classlib/src/main/java/org/threeten/bp/chrono/JapaneseEra.java +++ b/classlib/src/main/java/org/threeten/bp/chrono/JapaneseEra.java @@ -31,11 +31,6 @@ */ package org.threeten.bp.chrono; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.io.InvalidObjectException; -import java.io.ObjectStreamException; import java.io.Serializable; import java.util.Arrays; import java.util.Objects; @@ -97,11 +92,6 @@ public final class JapaneseEra */ private static final int ADDITIONAL_VALUE = 4; - /** - * Serialization version. - */ - private static final long serialVersionUID = 1466499369062886794L; - // array for the singleton JapaneseEra instances private static JapaneseEra[] KNOWN_ERAS; @@ -139,24 +129,6 @@ public final class JapaneseEra this.name = name; } - /** - * Returns the singleton {@code JapaneseEra} corresponding to this object. - * It's possible that this version of {@code JapaneseEra} doesn't support the latest era value. - * In that case, this method throws an {@code ObjectStreamException}. - * - * @return the singleton {@code JapaneseEra} for this object - * @throws ObjectStreamException if the deserialized object has any unknown numeric era value. - */ - private Object readResolve() throws ObjectStreamException { - try { - return of(eraValue); - } catch (DateTimeException e) { - InvalidObjectException ex = new InvalidObjectException("Invalid era"); - ex.initCause(e); - throw ex; - } - } - //----------------------------------------------------------------------- /** * Registers an additional instance of {@code JapaneseEra}. @@ -326,19 +298,4 @@ public final class JapaneseEra public String toString() { return name; } - - //----------------------------------------------------------------------- - private Object writeReplace() { - return new Ser(Ser.JAPANESE_ERA_TYPE, this); - } - - void writeExternal(DataOutput out) throws IOException { - out.writeByte(this.getValue()); - } - - static JapaneseEra readExternal(DataInput in) throws IOException { - byte eraValue = in.readByte(); - return JapaneseEra.of(eraValue); - } - } diff --git a/classlib/src/main/java/org/threeten/bp/chrono/MinguoChronology.java b/classlib/src/main/java/org/threeten/bp/chrono/MinguoChronology.java index 3c964d722..5af1f37ca 100644 --- a/classlib/src/main/java/org/threeten/bp/chrono/MinguoChronology.java +++ b/classlib/src/main/java/org/threeten/bp/chrono/MinguoChronology.java @@ -102,10 +102,6 @@ public final class MinguoChronology extends Chronology implements Serializable { */ public static final MinguoChronology INSTANCE = new MinguoChronology(); - /** - * Serialization version. - */ - private static final long serialVersionUID = 1039765215346859963L; /** * The difference in years between ISO and Minguo. */ diff --git a/classlib/src/main/java/org/threeten/bp/chrono/MinguoDate.java b/classlib/src/main/java/org/threeten/bp/chrono/MinguoDate.java index 67a3797a0..b824110bf 100644 --- a/classlib/src/main/java/org/threeten/bp/chrono/MinguoDate.java +++ b/classlib/src/main/java/org/threeten/bp/chrono/MinguoDate.java @@ -32,13 +32,8 @@ package org.threeten.bp.chrono; import static org.threeten.bp.chrono.MinguoChronology.YEARS_DIFFERENCE; -import static org.threeten.bp.temporal.ChronoField.DAY_OF_MONTH; -import static org.threeten.bp.temporal.ChronoField.MONTH_OF_YEAR; import static org.threeten.bp.temporal.ChronoField.YEAR; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; import java.io.Serializable; import java.util.Objects; @@ -72,11 +67,6 @@ public final class MinguoDate extends ChronoDateImpl implements Serializable { - /** - * Serialization version. - */ - private static final long serialVersionUID = 1300372329181994526L; - /** * The underlying date. */ @@ -356,26 +346,4 @@ public final class MinguoDate public int hashCode() { return getChronology().getId().hashCode() ^ isoDate.hashCode(); } - - //----------------------------------------------------------------------- - private Object writeReplace() { - return new Ser(Ser.MINGUO_DATE_TYPE, this); - } - - void writeExternal(DataOutput out) throws IOException { - // MinguoChrono is implicit in the MINGUO_DATE_TYPE - out.writeInt(get(YEAR)); - out.writeByte(get(MONTH_OF_YEAR)); - out.writeByte(get(DAY_OF_MONTH)); - - } - - static ChronoLocalDate readExternal(DataInput in) throws IOException { - int year = in.readInt(); - int month = in.readByte(); - int dayOfMonth = in.readByte(); - return MinguoChronology.INSTANCE.date(year, month, dayOfMonth); - } - - } diff --git a/classlib/src/main/java/org/threeten/bp/chrono/MinguoEra.java b/classlib/src/main/java/org/threeten/bp/chrono/MinguoEra.java index ab43955d8..fd5a85245 100644 --- a/classlib/src/main/java/org/threeten/bp/chrono/MinguoEra.java +++ b/classlib/src/main/java/org/threeten/bp/chrono/MinguoEra.java @@ -33,9 +33,6 @@ package org.threeten.bp.chrono; import static org.threeten.bp.temporal.ChronoField.ERA; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; import java.util.Locale; import org.threeten.bp.DateTimeException; @@ -172,19 +169,4 @@ public enum MinguoEra implements Era { public String getDisplayName(TextStyle style, Locale locale) { return new DateTimeFormatterBuilder().appendText(ERA, style).toFormatter(locale).format(this); } - - //----------------------------------------------------------------------- - private Object writeReplace() { - return new Ser(Ser.MINGUO_ERA_TYPE, this); - } - - void writeExternal(DataOutput out) throws IOException { - out.writeByte(this.getValue()); - } - - static MinguoEra readExternal(DataInput in) throws IOException { - byte eraValue = in.readByte(); - return MinguoEra.of(eraValue); - } - } diff --git a/classlib/src/main/java/org/threeten/bp/chrono/Ser.java b/classlib/src/main/java/org/threeten/bp/chrono/Ser.java deleted file mode 100644 index 73d44ca50..000000000 --- a/classlib/src/main/java/org/threeten/bp/chrono/Ser.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * * Neither the name of JSR-310 nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package org.threeten.bp.chrono; - -import java.io.Externalizable; -import java.io.IOException; -import java.io.InvalidClassException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.io.StreamCorruptedException; - -import org.threeten.bp.LocalDate; -import org.threeten.bp.LocalDateTime; - -/** - * The shared serialization delegate for this package. - * - *

Implementation notes

- * This class wraps the object being serialized, and takes a byte representing the type of the class to - * be serialized. This byte can also be used for versioning the serialization format. In this case another - * byte flag would be used in order to specify an alternative version of the type format. - * For example {@code JAPANESE_DATE_TYPE_VERSION_2 = 21}. - *

- * In order to serialise the object it writes its byte and then calls back to the appropriate class where - * the serialisation is performed. In order to deserialise the object it read in the type byte, switching - * in order to select which class to call back into. - *

- * The serialisation format is determined on a per class basis. In the case of field based classes each - * of the fields is written out with an appropriate size format in descending order of the field's size. For - * example in the case of {@link LocalDate} year is written before month. Composite classes, such as - * {@link LocalDateTime} are serialised as one object. - *

- * This class is mutable and should be created once per serialization. - * - * @serial include - */ -final class Ser implements Externalizable { - - /** - * Serialization version. - */ - private static final long serialVersionUID = 7857518227608961174L; - - static final byte JAPANESE_DATE_TYPE = 1; - static final byte JAPANESE_ERA_TYPE = 2; - static final byte HIJRAH_DATE_TYPE = 3; - static final byte HIJRAH_ERA_TYPE = 4; - static final byte MINGUO_DATE_TYPE = 5; - static final byte MINGUO_ERA_TYPE = 6; - static final byte THAIBUDDHIST_DATE_TYPE = 7; - static final byte THAIBUDDHIST_ERA_TYPE = 8; - static final byte CHRONO_TYPE = 11; - static final byte CHRONO_LOCALDATETIME_TYPE = 12; - static final byte CHRONO_ZONEDDATETIME_TYPE = 13; - - /** The type being serialized. */ - private byte type; - /** The object being serialized. */ - private Object object; - - /** - * Constructor for deserialization. - */ - public Ser() { - } - - /** - * Creates an instance for serialization. - * - * @param type the type - * @param object the object - */ - Ser(byte type, Object object) { - this.type = type; - this.object = object; - } - - //----------------------------------------------------------------------- - /** - * Implements the {@code Externalizable} interface to write the object. - * - * @param out the data stream to write to, not null - */ - @Override - public void writeExternal(ObjectOutput out) throws IOException { - writeInternal(type, object, out); - } - - private static void writeInternal(byte type, Object object, ObjectOutput out) throws IOException { - out.writeByte(type); - switch (type) { - case JAPANESE_DATE_TYPE: - ((JapaneseDate) object).writeExternal(out); - break; - case JAPANESE_ERA_TYPE: - ((JapaneseEra) object).writeExternal(out); - break; - case HIJRAH_DATE_TYPE: - ((HijrahDate) object).writeExternal(out); - break; - case HIJRAH_ERA_TYPE: - ((HijrahEra) object).writeExternal(out); - break; - case MINGUO_DATE_TYPE: - ((MinguoDate) object).writeExternal(out); - break; - case MINGUO_ERA_TYPE: - ((MinguoEra) object).writeExternal(out); - break; - case THAIBUDDHIST_DATE_TYPE: - ((ThaiBuddhistDate) object).writeExternal(out); - break; - case THAIBUDDHIST_ERA_TYPE: - ((ThaiBuddhistEra) object).writeExternal(out); - break; - case CHRONO_TYPE: - ((Chronology) object).writeExternal(out); - break; - case CHRONO_LOCALDATETIME_TYPE: - ((ChronoLocalDateTimeImpl) object).writeExternal(out); - break; - case CHRONO_ZONEDDATETIME_TYPE: - ((ChronoZonedDateTimeImpl) object).writeExternal(out); - break; - default: - throw new InvalidClassException("Unknown serialized type"); - } - } - - //----------------------------------------------------------------------- - /** - * Implements the {@code Externalizable} interface to read the object. - * - * @param in the data to read, not null - */ - @Override - public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { - type = in.readByte(); - object = readInternal(type, in); - } - - static Object read(ObjectInput in) throws IOException, ClassNotFoundException { - byte type = in.readByte(); - return readInternal(type, in); - } - - private static Object readInternal(byte type, ObjectInput in) throws IOException, ClassNotFoundException { - switch (type) { - case JAPANESE_DATE_TYPE: return JapaneseDate.readExternal(in); - case JAPANESE_ERA_TYPE: return JapaneseEra.readExternal(in); - case HIJRAH_DATE_TYPE: return HijrahDate.readExternal(in); - case HIJRAH_ERA_TYPE: return HijrahEra.readExternal(in); - case MINGUO_DATE_TYPE: return MinguoDate.readExternal(in); - case MINGUO_ERA_TYPE: return MinguoEra.readExternal(in); - case THAIBUDDHIST_DATE_TYPE: return ThaiBuddhistDate.readExternal(in); - case THAIBUDDHIST_ERA_TYPE: return ThaiBuddhistEra.readExternal(in); - case CHRONO_TYPE: return Chronology.readExternal(in); - case CHRONO_LOCALDATETIME_TYPE: return ChronoLocalDateTimeImpl.readExternal(in); - case CHRONO_ZONEDDATETIME_TYPE: return ChronoZonedDateTimeImpl.readExternal(in); - default: - throw new StreamCorruptedException("Unknown serialized type"); - } - } - - /** - * Returns the object that will replace this one. - * - * @return the read object, should never be null - */ - private Object readResolve() { - return object; - } - -} diff --git a/classlib/src/main/java/org/threeten/bp/chrono/ThaiBuddhistChronology.java b/classlib/src/main/java/org/threeten/bp/chrono/ThaiBuddhistChronology.java index c8c632f3e..994ec8f75 100644 --- a/classlib/src/main/java/org/threeten/bp/chrono/ThaiBuddhistChronology.java +++ b/classlib/src/main/java/org/threeten/bp/chrono/ThaiBuddhistChronology.java @@ -103,10 +103,6 @@ public final class ThaiBuddhistChronology extends Chronology implements Serializ */ public static final ThaiBuddhistChronology INSTANCE = new ThaiBuddhistChronology(); - /** - * Serialization version. - */ - private static final long serialVersionUID = 2775954514031616474L; /** * Containing the offset to add to the ISO year. */ diff --git a/classlib/src/main/java/org/threeten/bp/chrono/ThaiBuddhistDate.java b/classlib/src/main/java/org/threeten/bp/chrono/ThaiBuddhistDate.java index d9dfa1a42..c015dc90e 100644 --- a/classlib/src/main/java/org/threeten/bp/chrono/ThaiBuddhistDate.java +++ b/classlib/src/main/java/org/threeten/bp/chrono/ThaiBuddhistDate.java @@ -36,9 +36,6 @@ import static org.threeten.bp.temporal.ChronoField.DAY_OF_MONTH; import static org.threeten.bp.temporal.ChronoField.MONTH_OF_YEAR; import static org.threeten.bp.temporal.ChronoField.YEAR; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; import java.io.Serializable; import java.util.Objects; @@ -72,11 +69,6 @@ public final class ThaiBuddhistDate extends ChronoDateImpl implements Serializable { - /** - * Serialization version. - */ - private static final long serialVersionUID = -8722293800195731463L; - /** * The underlying date. */ @@ -356,24 +348,4 @@ public final class ThaiBuddhistDate public int hashCode() { return getChronology().getId().hashCode() ^ isoDate.hashCode(); } - - //----------------------------------------------------------------------- - private Object writeReplace() { - return new Ser(Ser.THAIBUDDHIST_DATE_TYPE, this); - } - - void writeExternal(DataOutput out) throws IOException { - // MinguoChrono is implicit in the THAIBUDDHIST_DATE_TYPE - out.writeInt(this.get(YEAR)); - out.writeByte(this.get(MONTH_OF_YEAR)); - out.writeByte(this.get(DAY_OF_MONTH)); - } - - static ChronoLocalDate readExternal(DataInput in) throws IOException { - int year = in.readInt(); - int month = in.readByte(); - int dayOfMonth = in.readByte(); - return ThaiBuddhistChronology.INSTANCE.date(year, month, dayOfMonth); - } - } diff --git a/classlib/src/main/java/org/threeten/bp/chrono/ThaiBuddhistEra.java b/classlib/src/main/java/org/threeten/bp/chrono/ThaiBuddhistEra.java index 2c56cf40f..0d06cca65 100644 --- a/classlib/src/main/java/org/threeten/bp/chrono/ThaiBuddhistEra.java +++ b/classlib/src/main/java/org/threeten/bp/chrono/ThaiBuddhistEra.java @@ -33,9 +33,6 @@ package org.threeten.bp.chrono; import static org.threeten.bp.temporal.ChronoField.ERA; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; import java.util.Locale; import org.threeten.bp.DateTimeException; @@ -171,19 +168,4 @@ public enum ThaiBuddhistEra implements Era { public String getDisplayName(TextStyle style, Locale locale) { return new DateTimeFormatterBuilder().appendText(ERA, style).toFormatter(locale).format(this); } - - //----------------------------------------------------------------------- - private Object writeReplace() { - return new Ser(Ser.THAIBUDDHIST_ERA_TYPE, this); - } - - void writeExternal(DataOutput out) throws IOException { - out.writeByte(this.getValue()); - } - - static ThaiBuddhistEra readExternal(DataInput in) throws IOException { - byte eraValue = in.readByte(); - return ThaiBuddhistEra.of(eraValue); - } - } diff --git a/classlib/src/main/java/org/threeten/bp/format/DateTimeParseException.java b/classlib/src/main/java/org/threeten/bp/format/DateTimeParseException.java index b2b6fe83a..54377f02d 100644 --- a/classlib/src/main/java/org/threeten/bp/format/DateTimeParseException.java +++ b/classlib/src/main/java/org/threeten/bp/format/DateTimeParseException.java @@ -43,11 +43,6 @@ import org.threeten.bp.DateTimeException; */ public class DateTimeParseException extends DateTimeException { - /** - * Serialization version. - */ - private static final long serialVersionUID = 4304633501674722597L; - /** * The text that was being parsed. */ diff --git a/classlib/src/main/java/org/threeten/bp/temporal/UnsupportedTemporalTypeException.java b/classlib/src/main/java/org/threeten/bp/temporal/UnsupportedTemporalTypeException.java index 7cfc113c4..11e4a99f2 100644 --- a/classlib/src/main/java/org/threeten/bp/temporal/UnsupportedTemporalTypeException.java +++ b/classlib/src/main/java/org/threeten/bp/temporal/UnsupportedTemporalTypeException.java @@ -41,11 +41,6 @@ import org.threeten.bp.DateTimeException; */ public class UnsupportedTemporalTypeException extends DateTimeException { - /** - * Serialization version. - */ - private static final long serialVersionUID = -189676278478L; - /** * Constructs a new date-time exception with the specified message. * diff --git a/classlib/src/main/java/org/threeten/bp/temporal/ValueRange.java b/classlib/src/main/java/org/threeten/bp/temporal/ValueRange.java index e21a3927b..2c26e436e 100644 --- a/classlib/src/main/java/org/threeten/bp/temporal/ValueRange.java +++ b/classlib/src/main/java/org/threeten/bp/temporal/ValueRange.java @@ -55,11 +55,6 @@ import org.threeten.bp.DateTimeException; */ public final class ValueRange implements Serializable { - /** - * Serialization version. - */ - private static final long serialVersionUID = -7317881728594519368L; - /** * The smallest minimum value. */ diff --git a/classlib/src/main/java/org/threeten/bp/temporal/WeekFields.java b/classlib/src/main/java/org/threeten/bp/temporal/WeekFields.java index 02ff63d76..da55ccbe0 100644 --- a/classlib/src/main/java/org/threeten/bp/temporal/WeekFields.java +++ b/classlib/src/main/java/org/threeten/bp/temporal/WeekFields.java @@ -151,11 +151,6 @@ public final class WeekFields implements Serializable { */ public static final WeekFields SUNDAY_START = WeekFields.of(DayOfWeek.SUNDAY, 1); - /** - * Serialization version. - */ - private static final long serialVersionUID = -1177360819670808121L; - /** * The first day-of-week. */ diff --git a/classlib/src/main/java/org/threeten/bp/zone/Ser.java b/classlib/src/main/java/org/threeten/bp/zone/Ser.java deleted file mode 100644 index 1f9def050..000000000 --- a/classlib/src/main/java/org/threeten/bp/zone/Ser.java +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * * Neither the name of JSR-310 nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package org.threeten.bp.zone; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.Externalizable; -import java.io.IOException; -import java.io.InvalidClassException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.io.StreamCorruptedException; - -import org.threeten.bp.ZoneOffset; - -/** - * The shared serialization delegate for this package. - * - *

Implementation notes

- * This class is mutable and should be created once per serialization. - * - * @serial include - */ -final class Ser implements Externalizable { - - /** - * Serialization version. - */ - private static final long serialVersionUID = -8885321777449118786L; - - /** Type for StandardZoneRules. */ - static final byte SZR = 1; - /** Type for ZoneOffsetTransition. */ - static final byte ZOT = 2; - /** Type for ZoneOffsetTransition. */ - static final byte ZOTRULE = 3; - - /** The type being serialized. */ - private byte type; - /** The object being serialized. */ - private Object object; - - /** - * Constructor for deserialization. - */ - public Ser() { - } - - /** - * Creates an instance for serialization. - * - * @param type the type - * @param object the object - */ - Ser(byte type, Object object) { - this.type = type; - this.object = object; - } - - //----------------------------------------------------------------------- - /** - * Implements the {@code Externalizable} interface to write the object. - * - * @param out the data stream to write to, not null - */ - public void writeExternal(ObjectOutput out) throws IOException { - writeInternal(type, object, out); - } - - static void write(Object object, DataOutput out) throws IOException { - writeInternal(SZR, object, out); - } - - private static void writeInternal(byte type, Object object, DataOutput out) throws IOException { - out.writeByte(type); - switch (type) { - case SZR: - ((StandardZoneRules) object).writeExternal(out); - break; - case ZOT: - ((ZoneOffsetTransition) object).writeExternal(out); - break; - case ZOTRULE: - ((ZoneOffsetTransitionRule) object).writeExternal(out); - break; - default: - throw new InvalidClassException("Unknown serialized type"); - } - } - - //----------------------------------------------------------------------- - /** - * Implements the {@code Externalizable} interface to read the object. - * - * @param in the data to read, not null - */ - public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { - type = in.readByte(); - object = readInternal(type, in); - } - - static Object read(DataInput in) throws IOException, ClassNotFoundException { - byte type = in.readByte(); - return readInternal(type, in); - } - - private static Object readInternal(byte type, DataInput in) throws IOException, ClassNotFoundException { - switch (type) { - case SZR: - return StandardZoneRules.readExternal(in); - case ZOT: - return ZoneOffsetTransition.readExternal(in); - case ZOTRULE: - return ZoneOffsetTransitionRule.readExternal(in); - default: - throw new StreamCorruptedException("Unknown serialized type"); - } - } - - /** - * Returns the object that will replace this one. - * - * @return the read object, should never be null - */ - private Object readResolve() { - return object; - } - - //----------------------------------------------------------------------- - /** - * Writes the state to the stream. - * - * @param offset the offset, not null - * @param out the output stream, not null - * @throws IOException if an error occurs - */ - static void writeOffset(ZoneOffset offset, DataOutput out) throws IOException { - final int offsetSecs = offset.getTotalSeconds(); - int offsetByte = offsetSecs % 900 == 0 ? offsetSecs / 900 : 127; // compress to -72 to +72 - out.writeByte(offsetByte); - if (offsetByte == 127) { - out.writeInt(offsetSecs); - } - } - - /** - * Reads the state from the stream. - * - * @param in the input stream, not null - * @return the created object, not null - * @throws IOException if an error occurs - */ - static ZoneOffset readOffset(DataInput in) throws IOException { - int offsetByte = in.readByte(); - return (offsetByte == 127 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds(offsetByte * 900)); - } - - //----------------------------------------------------------------------- - /** - * Writes the state to the stream. - * - * @param epochSec the epoch seconds, not null - * @param out the output stream, not null - * @throws IOException if an error occurs - */ - static void writeEpochSec(long epochSec, DataOutput out) throws IOException { - if (epochSec >= -4575744000L && epochSec < 10413792000L && epochSec % 900 == 0) { // quarter hours between 1825 and 2300 - int store = (int) ((epochSec + 4575744000L) / 900); - out.writeByte((store >>> 16) & 255); - out.writeByte((store >>> 8) & 255); - out.writeByte(store & 255); - } else { - out.writeByte(255); - out.writeLong(epochSec); - } - } - - /** - * Reads the state from the stream. - * - * @param in the input stream, not null - * @return the epoch seconds, not null - * @throws IOException if an error occurs - */ - static long readEpochSec(DataInput in) throws IOException { - int hiByte = in.readByte() & 255; - if (hiByte == 255) { - return in.readLong(); - } else { - int midByte = in.readByte() & 255; - int loByte = in.readByte() & 255; - long tot = ((hiByte << 16) + (midByte << 8) + loByte); - return (tot * 900) - 4575744000L; - } - } - -} diff --git a/classlib/src/main/java/org/threeten/bp/zone/StandardZoneRules.java b/classlib/src/main/java/org/threeten/bp/zone/StandardZoneRules.java index e4c661e3c..58a20a654 100644 --- a/classlib/src/main/java/org/threeten/bp/zone/StandardZoneRules.java +++ b/classlib/src/main/java/org/threeten/bp/zone/StandardZoneRules.java @@ -31,9 +31,6 @@ */ package org.threeten.bp.zone; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; @@ -59,11 +56,6 @@ import org.threeten.bp.jdk8.Jdk8Methods; * This class is immutable and thread-safe. */ final class StandardZoneRules extends ZoneRules implements Serializable { - - /** - * Serialization version. - */ - private static final long serialVersionUID = 3044319355680032515L; /** * The last year to have its transitions cached. */ @@ -196,77 +188,6 @@ final class StandardZoneRules extends ZoneRules implements Serializable { this.savingsLocalTransitions = localTransitionList.toArray(new LocalDateTime[localTransitionList.size()]); } - //----------------------------------------------------------------------- - /** - * Uses a serialization delegate. - * - * @return the replacing object, not null - */ - private Object writeReplace() { - return new Ser(Ser.SZR, this); - } - - /** - * Writes the state to the stream. - * - * @param out the output stream, not null - * @throws IOException if an error occurs - */ - void writeExternal(DataOutput out) throws IOException { - out.writeInt(standardTransitions.length); - for (long trans : standardTransitions) { - Ser.writeEpochSec(trans, out); - } - for (ZoneOffset offset : standardOffsets) { - Ser.writeOffset(offset, out); - } - out.writeInt(savingsInstantTransitions.length); - for (long trans : savingsInstantTransitions) { - Ser.writeEpochSec(trans, out); - } - for (ZoneOffset offset : wallOffsets) { - Ser.writeOffset(offset, out); - } - out.writeByte(lastRules.length); - for (ZoneOffsetTransitionRule rule : lastRules) { - rule.writeExternal(out); - } - } - - /** - * Reads the state from the stream. - * - * @param in the input stream, not null - * @return the created object, not null - * @throws IOException if an error occurs - */ - static StandardZoneRules readExternal(DataInput in) throws IOException, ClassNotFoundException { - int stdSize = in.readInt(); - long[] stdTrans = new long[stdSize]; - for (int i = 0; i < stdSize; i++) { - stdTrans[i] = Ser.readEpochSec(in); - } - ZoneOffset[] stdOffsets = new ZoneOffset[stdSize + 1]; - for (int i = 0; i < stdOffsets.length; i++) { - stdOffsets[i] = Ser.readOffset(in); - } - int savSize = in.readInt(); - long[] savTrans = new long[savSize]; - for (int i = 0; i < savSize; i++) { - savTrans[i] = Ser.readEpochSec(in); - } - ZoneOffset[] savOffsets = new ZoneOffset[savSize + 1]; - for (int i = 0; i < savOffsets.length; i++) { - savOffsets[i] = Ser.readOffset(in); - } - int ruleSize = in.readByte(); - ZoneOffsetTransitionRule[] rules = new ZoneOffsetTransitionRule[ruleSize]; - for (int i = 0; i < ruleSize; i++) { - rules[i] = ZoneOffsetTransitionRule.readExternal(in); - } - return new StandardZoneRules(stdTrans, stdOffsets, savTrans, savOffsets, rules); - } - //----------------------------------------------------------------------- @Override public boolean isFixedOffset() { diff --git a/classlib/src/main/java/org/threeten/bp/zone/TzdbZoneRulesCompiler.java b/classlib/src/main/java/org/threeten/bp/zone/TzdbZoneRulesCompiler.java index df72ddc2c..b4ebd2463 100644 --- a/classlib/src/main/java/org/threeten/bp/zone/TzdbZoneRulesCompiler.java +++ b/classlib/src/main/java/org/threeten/bp/zone/TzdbZoneRulesCompiler.java @@ -414,7 +414,7 @@ final class TzdbZoneRulesCompiler { for (ZoneRules rules : rulesList) { baos.reset(); DataOutputStream dataos = new DataOutputStream(baos); - Ser.write(rules, dataos); + //Ser.write(rules, dataos); dataos.close(); byte[] bytes = baos.toByteArray(); out.writeShort(bytes.length); diff --git a/classlib/src/main/java/org/threeten/bp/zone/TzdbZoneRulesProvider.java b/classlib/src/main/java/org/threeten/bp/zone/TzdbZoneRulesProvider.java index a111eae08..5aebaf5d5 100644 --- a/classlib/src/main/java/org/threeten/bp/zone/TzdbZoneRulesProvider.java +++ b/classlib/src/main/java/org/threeten/bp/zone/TzdbZoneRulesProvider.java @@ -50,8 +50,6 @@ import java.util.concurrent.ConcurrentSkipListMap; import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.atomic.AtomicReferenceArray; -import org.threeten.bp.jdk8.Jdk8Methods; - /** * Loads time-zone rules for 'TZDB'. *

@@ -316,7 +314,7 @@ public final class TzdbZoneRulesProvider extends ZoneRulesProvider { if (obj instanceof byte[]) { byte[] bytes = (byte[]) obj; DataInputStream dis = new DataInputStream(new ByteArrayInputStream(bytes)); - obj = Ser.read(dis); + obj = null; //Ser.read(dis); ruleData.set(index, obj); } return (ZoneRules) obj; diff --git a/classlib/src/main/java/org/threeten/bp/zone/ZoneOffsetTransition.java b/classlib/src/main/java/org/threeten/bp/zone/ZoneOffsetTransition.java index 562500475..aad507408 100644 --- a/classlib/src/main/java/org/threeten/bp/zone/ZoneOffsetTransition.java +++ b/classlib/src/main/java/org/threeten/bp/zone/ZoneOffsetTransition.java @@ -31,9 +31,6 @@ */ package org.threeten.bp.zone; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; import java.io.Serializable; import java.util.Arrays; import java.util.Collections; @@ -66,10 +63,6 @@ import org.threeten.bp.ZoneOffset; public final class ZoneOffsetTransition implements Comparable, Serializable { - /** - * Serialization version. - */ - private static final long serialVersionUID = -6946044323557704546L; /** * The local transition date-time at the transition. */ @@ -137,45 +130,6 @@ public final class ZoneOffsetTransition this.offsetAfter = offsetAfter; } - //----------------------------------------------------------------------- - /** - * Uses a serialization delegate. - * - * @return the replacing object, not null - */ - private Object writeReplace() { - return new Ser(Ser.ZOT, this); - } - - /** - * Writes the state to the stream. - * - * @param out the output stream, not null - * @throws IOException if an error occurs - */ - void writeExternal(DataOutput out) throws IOException { - Ser.writeEpochSec(toEpochSecond(), out); - Ser.writeOffset(offsetBefore, out); - Ser.writeOffset(offsetAfter, out); - } - - /** - * Reads the state from the stream. - * - * @param in the input stream, not null - * @return the created object, not null - * @throws IOException if an error occurs - */ - static ZoneOffsetTransition readExternal(DataInput in) throws IOException { - long epochSecond = Ser.readEpochSec(in); - ZoneOffset before = Ser.readOffset(in); - ZoneOffset after = Ser.readOffset(in); - if (before.equals(after)) { - throw new IllegalArgumentException("Offsets must not be equal"); - } - return new ZoneOffsetTransition(epochSecond, before, after); - } - //----------------------------------------------------------------------- /** * Gets the transition instant. diff --git a/classlib/src/main/java/org/threeten/bp/zone/ZoneOffsetTransitionRule.java b/classlib/src/main/java/org/threeten/bp/zone/ZoneOffsetTransitionRule.java index aeaa1050c..17843e959 100644 --- a/classlib/src/main/java/org/threeten/bp/zone/ZoneOffsetTransitionRule.java +++ b/classlib/src/main/java/org/threeten/bp/zone/ZoneOffsetTransitionRule.java @@ -34,9 +34,6 @@ package org.threeten.bp.zone; import static org.threeten.bp.temporal.TemporalAdjusters.nextOrSame; import static org.threeten.bp.temporal.TemporalAdjusters.previousOrSame; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; import java.io.Serializable; import java.util.Objects; @@ -67,10 +64,6 @@ import org.threeten.bp.jdk8.Jdk8Methods; */ public final class ZoneOffsetTransitionRule implements Serializable { - /** - * Serialization version. - */ - private static final long serialVersionUID = 6889046316657758795L; /** * The number of seconds per day. */ @@ -203,87 +196,6 @@ public final class ZoneOffsetTransitionRule implements Serializable { this.offsetAfter = offsetAfter; } - //----------------------------------------------------------------------- - /** - * Uses a serialization delegate. - * - * @return the replacing object, not null - */ - private Object writeReplace() { - return new Ser(Ser.ZOTRULE, this); - } - - /** - * Writes the state to the stream. - * - * @param out the output stream, not null - * @throws IOException if an error occurs - */ - void writeExternal(DataOutput out) throws IOException { - final int timeSecs = time.toSecondOfDay() + adjustDays * SECS_PER_DAY; - final int stdOffset = standardOffset.getTotalSeconds(); - final int beforeDiff = offsetBefore.getTotalSeconds() - stdOffset; - final int afterDiff = offsetAfter.getTotalSeconds() - stdOffset; - final int timeByte = (timeSecs % 3600 == 0 && timeSecs <= SECS_PER_DAY ? - (timeSecs == SECS_PER_DAY ? 24 : time.getHour()) : 31); - final int stdOffsetByte = (stdOffset % 900 == 0 ? stdOffset / 900 + 128 : 255); - final int beforeByte = (beforeDiff == 0 || beforeDiff == 1800 || beforeDiff == 3600 ? beforeDiff / 1800 : 3); - final int afterByte = (afterDiff == 0 || afterDiff == 1800 || afterDiff == 3600 ? afterDiff / 1800 : 3); - final int dowByte = (dow == null ? 0 : dow.getValue()); - int b = (month.getValue() << 28) + // 4 bits - ((dom + 32) << 22) + // 6 bits - (dowByte << 19) + // 3 bits - (timeByte << 14) + // 5 bits - (timeDefinition.ordinal() << 12) + // 2 bits - (stdOffsetByte << 4) + // 8 bits - (beforeByte << 2) + // 2 bits - afterByte; // 2 bits - out.writeInt(b); - if (timeByte == 31) { - out.writeInt(timeSecs); - } - if (stdOffsetByte == 255) { - out.writeInt(stdOffset); - } - if (beforeByte == 3) { - out.writeInt(offsetBefore.getTotalSeconds()); - } - if (afterByte == 3) { - out.writeInt(offsetAfter.getTotalSeconds()); - } - } - - /** - * Reads the state from the stream. - * - * @param in the input stream, not null - * @return the created object, not null - * @throws IOException if an error occurs - */ - static ZoneOffsetTransitionRule readExternal(DataInput in) throws IOException { - int data = in.readInt(); - Month month = Month.of(data >>> 28); - int dom = ((data & (63 << 22)) >>> 22) - 32; - int dowByte = (data & (7 << 19)) >>> 19; - DayOfWeek dow = dowByte == 0 ? null : DayOfWeek.of(dowByte); - int timeByte = (data & (31 << 14)) >>> 14; - TimeDefinition defn = TimeDefinition.values()[(data & (3 << 12)) >>> 12]; - int stdByte = (data & (255 << 4)) >>> 4; - int beforeByte = (data & (3 << 2)) >>> 2; - int afterByte = (data & 3); - int timeOfDaysSecs = (timeByte == 31 ? in.readInt() : timeByte * 3600); - ZoneOffset std = (stdByte == 255 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds((stdByte - 128) * 900)); - ZoneOffset before = (beforeByte == 3 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds(std.getTotalSeconds() + beforeByte * 1800)); - ZoneOffset after = (afterByte == 3 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds(std.getTotalSeconds() + afterByte * 1800)); - // only bit of validation that we need to copy from public of() method - if (dom < -28 || dom > 31 || dom == 0) { - throw new IllegalArgumentException("Day of month indicator must be between -28 and 31 inclusive excluding zero"); - } - LocalTime time = LocalTime.ofSecondOfDay(Jdk8Methods.floorMod(timeOfDaysSecs, SECS_PER_DAY)); - int adjustDays = Jdk8Methods.floorDiv(timeOfDaysSecs, SECS_PER_DAY); - return new ZoneOffsetTransitionRule(month, dom, dow, time, adjustDays, defn, std, before, after); - } - //----------------------------------------------------------------------- /** * Gets the month of the transition. diff --git a/classlib/src/main/java/org/threeten/bp/zone/ZoneRules.java b/classlib/src/main/java/org/threeten/bp/zone/ZoneRules.java index a95c961b5..55b247861 100644 --- a/classlib/src/main/java/org/threeten/bp/zone/ZoneRules.java +++ b/classlib/src/main/java/org/threeten/bp/zone/ZoneRules.java @@ -400,8 +400,6 @@ public abstract class ZoneRules { * Fixed time-zone. */ static final class Fixed extends ZoneRules implements Serializable { - /** A serialization identifier for this class. */ - private static final long serialVersionUID = -8733721350312276297L; /** The offset. */ private final ZoneOffset offset; diff --git a/classlib/src/main/java/org/threeten/bp/zone/ZoneRulesException.java b/classlib/src/main/java/org/threeten/bp/zone/ZoneRulesException.java index 186a9874c..7019c93be 100644 --- a/classlib/src/main/java/org/threeten/bp/zone/ZoneRulesException.java +++ b/classlib/src/main/java/org/threeten/bp/zone/ZoneRulesException.java @@ -44,11 +44,6 @@ import org.threeten.bp.DateTimeException; */ public class ZoneRulesException extends DateTimeException { - /** - * Serialization version. - */ - private static final long serialVersionUID = -1632418723876261839L; - /** * Constructs a new date-time exception with the specified message. *