8229997: Apply java.io.Serial annotations in java.base

Reviewed-by: alanb, rriggs
This commit is contained in:
Joe Darcy 2019-08-29 16:31:34 -07:00
parent 6d064a747e
commit 9d764ee48e
315 changed files with 880 additions and 254 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -729,6 +729,7 @@ public abstract class AbstractChronology implements Chronology {
*
* @return the instance of {@code Ser}, not null
*/
@java.io.Serial
Object writeReplace() {
return new Ser(Ser.CHRONO_TYPE, this);
}
@ -739,6 +740,7 @@ public abstract class AbstractChronology implements Chronology {
* @param s the stream to read
* @throws java.io.InvalidObjectException always
*/
@java.io.Serial
private void readObject(ObjectInputStream s) throws ObjectStreamException {
throw new InvalidObjectException("Deserialization via serialization delegate");
}

View file

@ -146,6 +146,7 @@ abstract class ChronoLocalDateImpl<D extends ChronoLocalDate>
/**
* Serialization version.
*/
@java.io.Serial
private static final long serialVersionUID = 6282433883239719096L;
/**

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -103,6 +103,7 @@ final class ChronoLocalDateTimeImpl<D extends ChronoLocalDate>
/**
* Serialization version.
*/
@java.io.Serial
private static final long serialVersionUID = 4556003607393004514L;
/**
* Hours per day.
@ -409,6 +410,7 @@ final class ChronoLocalDateTimeImpl<D extends ChronoLocalDate>
*
* @return the instance of {@code Ser}, not null
*/
@java.io.Serial
private Object writeReplace() {
return new Ser(Ser.CHRONO_LOCAL_DATE_TIME_TYPE, this);
}
@ -419,6 +421,7 @@ final class ChronoLocalDateTimeImpl<D extends ChronoLocalDate>
* @param s the stream to read
* @throws InvalidObjectException always
*/
@java.io.Serial
private void readObject(ObjectInputStream s) throws InvalidObjectException {
throw new InvalidObjectException("Deserialization via serialization delegate");
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -98,6 +98,7 @@ final class ChronoPeriodImpl
/**
* Serialization version.
*/
@java.io.Serial
private static final long serialVersionUID = 57387258289L;
/**
@ -366,6 +367,7 @@ final class ChronoPeriodImpl
*
* @return the instance of {@code Ser}, not null
*/
@java.io.Serial
protected Object writeReplace() {
return new Ser(Ser.CHRONO_PERIOD_TYPE, this);
}
@ -376,6 +378,7 @@ final class ChronoPeriodImpl
* @param s the stream to read
* @throws InvalidObjectException always
*/
@java.io.Serial
private void readObject(ObjectInputStream s) throws ObjectStreamException {
throw new InvalidObjectException("Deserialization via serialization delegate");
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -107,6 +107,7 @@ final class ChronoZonedDateTimeImpl<D extends ChronoLocalDate>
/**
* Serialization version.
*/
@java.io.Serial
private static final long serialVersionUID = -5261813987200935591L;
/**
@ -333,6 +334,7 @@ final class ChronoZonedDateTimeImpl<D extends ChronoLocalDate>
*
* @return the instance of {@code Ser}, not null
*/
@java.io.Serial
private Object writeReplace() {
return new Ser(Ser.CHRONO_ZONE_DATE_TIME_TYPE, this);
}
@ -343,6 +345,7 @@ final class ChronoZonedDateTimeImpl<D extends ChronoLocalDate>
* @param s the stream to read
* @throws InvalidObjectException always
*/
@java.io.Serial
private void readObject(ObjectInputStream s) throws InvalidObjectException {
throw new InvalidObjectException("Deserialization via serialization delegate");
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -205,6 +205,7 @@ public final class HijrahChronology extends AbstractChronology implements Serial
/**
* Serialization version.
*/
@java.io.Serial
private static final long serialVersionUID = 3127340209035924785L;
/**
* Singleton instance of the Islamic Umm Al-Qura calendar of Saudi Arabia.
@ -1021,6 +1022,7 @@ public final class HijrahChronology extends AbstractChronology implements Serial
* @return the instance of {@code Ser}, not null
*/
@Override
@java.io.Serial
Object writeReplace() {
return super.writeReplace();
}
@ -1031,6 +1033,7 @@ public final class HijrahChronology extends AbstractChronology implements Serial
* @param s the stream to read
* @throws InvalidObjectException always
*/
@java.io.Serial
private void readObject(ObjectInputStream s) throws InvalidObjectException {
throw new InvalidObjectException("Deserialization via serialization delegate");
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -123,6 +123,7 @@ public final class HijrahDate
/**
* Serialization version.
*/
@java.io.Serial
private static final long serialVersionUID = -5207853542612002020L;
/**
* The Chronology of this HijrahDate.
@ -657,6 +658,7 @@ public final class HijrahDate
* @param s the stream to read
* @throws InvalidObjectException always
*/
@java.io.Serial
private void readObject(ObjectInputStream s) throws InvalidObjectException {
throw new InvalidObjectException("Deserialization via serialization delegate");
}
@ -675,6 +677,7 @@ public final class HijrahDate
*
* @return the instance of {@code Ser}, not null
*/
@java.io.Serial
private Object writeReplace() {
return new Ser(Ser.HIJRAH_DATE_TYPE, this);
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -133,6 +133,7 @@ public final class IsoChronology extends AbstractChronology implements Serializa
/**
* Serialization version.
*/
@java.io.Serial
private static final long serialVersionUID = -1440403870442975015L;
private static final long DAYS_0000_TO_1970 = (146097 * 5L) - (30L * 365L + 7L); // taken from LocalDate
@ -689,6 +690,7 @@ public final class IsoChronology extends AbstractChronology implements Serializa
* @return the instance of {@code Ser}, not null
*/
@Override
@java.io.Serial
Object writeReplace() {
return super.writeReplace();
}
@ -699,6 +701,7 @@ public final class IsoChronology extends AbstractChronology implements Serializa
* @param s the stream to read
* @throws InvalidObjectException always
*/
@java.io.Serial
private void readObject(ObjectInputStream s) throws InvalidObjectException {
throw new InvalidObjectException("Deserialization via serialization delegate");
}

View file

@ -135,6 +135,7 @@ public final class JapaneseChronology extends AbstractChronology implements Seri
/**
* Serialization version.
*/
@java.io.Serial
private static final long serialVersionUID = 459996390165777884L;
//-----------------------------------------------------------------------
@ -516,6 +517,7 @@ public final class JapaneseChronology extends AbstractChronology implements Seri
* @return the instance of {@code Ser}, not null
*/
@Override
@java.io.Serial
Object writeReplace() {
return super.writeReplace();
}
@ -526,6 +528,7 @@ public final class JapaneseChronology extends AbstractChronology implements Seri
* @param s the stream to read
* @throws InvalidObjectException always
*/
@java.io.Serial
private void readObject(ObjectInputStream s) throws InvalidObjectException {
throw new InvalidObjectException("Deserialization via serialization delegate");
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -130,6 +130,7 @@ public final class JapaneseDate
/**
* Serialization version.
*/
@java.io.Serial
private static final long serialVersionUID = -305327627230580483L;
/**
@ -719,6 +720,7 @@ public final class JapaneseDate
* @param s the stream to read
* @throws InvalidObjectException always
*/
@java.io.Serial
private void readObject(ObjectInputStream s) throws InvalidObjectException {
throw new InvalidObjectException("Deserialization via serialization delegate");
}
@ -736,6 +738,7 @@ public final class JapaneseDate
*
* @return the instance of {@code Ser}, not null
*/
@java.io.Serial
private Object writeReplace() {
return new Ser(Ser.JAPANESE_DATE_TYPE, this);
}

View file

@ -166,6 +166,7 @@ public final class JapaneseEra
/**
* Serialization version.
*/
@java.io.Serial
private static final long serialVersionUID = 1466499369062886794L;
// array for the singleton JapaneseEra instances
@ -426,6 +427,7 @@ public final class JapaneseEra
* @param s the stream to read
* @throws InvalidObjectException always
*/
@java.io.Serial
private void readObject(ObjectInputStream s) throws InvalidObjectException {
throw new InvalidObjectException("Deserialization via serialization delegate");
}
@ -442,6 +444,7 @@ public final class JapaneseEra
*
* @return the instance of {@code Ser}, not null
*/
@java.io.Serial
private Object writeReplace() {
return new Ser(Ser.JAPANESE_ERA_TYPE, this);
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -114,6 +114,7 @@ public final class MinguoChronology extends AbstractChronology implements Serial
/**
* Serialization version.
*/
@java.io.Serial
private static final long serialVersionUID = 1039765215346859963L;
/**
* The difference in years between ISO and Minguo.
@ -347,6 +348,7 @@ public final class MinguoChronology extends AbstractChronology implements Serial
* @return the instance of {@code Ser}, not null
*/
@Override
@java.io.Serial
Object writeReplace() {
return super.writeReplace();
}
@ -357,6 +359,7 @@ public final class MinguoChronology extends AbstractChronology implements Serial
* @param s the stream to read
* @throws InvalidObjectException always
*/
@java.io.Serial
private void readObject(ObjectInputStream s) throws InvalidObjectException {
throw new InvalidObjectException("Deserialization via serialization delegate");
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -110,6 +110,7 @@ public final class MinguoDate
/**
* Serialization version.
*/
@java.io.Serial
private static final long serialVersionUID = 1300372329181994526L;
/**
@ -481,6 +482,7 @@ public final class MinguoDate
* @param s the stream to read
* @throws InvalidObjectException always
*/
@java.io.Serial
private void readObject(ObjectInputStream s) throws InvalidObjectException {
throw new InvalidObjectException("Deserialization via serialization delegate");
}
@ -498,6 +500,7 @@ public final class MinguoDate
*
* @return the instance of {@code Ser}, not null
*/
@java.io.Serial
private Object writeReplace() {
return new Ser(Ser.MINGUO_DATE_TYPE, this);
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -94,6 +94,7 @@ final class Ser implements Externalizable {
/**
* Serialization version.
*/
@java.io.Serial
private static final long serialVersionUID = -6103370247208168577L;
static final byte CHRONO_TYPE = 1;
@ -249,6 +250,7 @@ final class Ser implements Externalizable {
*
* @return the read object, should never be null
*/
@java.io.Serial
private Object readResolve() {
return object;
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -116,6 +116,7 @@ public final class ThaiBuddhistChronology extends AbstractChronology implements
/**
* Serialization version.
*/
@java.io.Serial
private static final long serialVersionUID = 2775954514031616474L;
/**
* Containing the offset to add to the ISO year.
@ -384,6 +385,7 @@ public final class ThaiBuddhistChronology extends AbstractChronology implements
* @return the instance of {@code Ser}, not null
*/
@Override
@java.io.Serial
Object writeReplace() {
return super.writeReplace();
}
@ -394,6 +396,7 @@ public final class ThaiBuddhistChronology extends AbstractChronology implements
* @param s the stream to read
* @throws InvalidObjectException always
*/
@java.io.Serial
private void readObject(ObjectInputStream s) throws InvalidObjectException {
throw new InvalidObjectException("Deserialization via serialization delegate");
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -110,6 +110,7 @@ public final class ThaiBuddhistDate
/**
* Serialization version.
*/
@java.io.Serial
private static final long serialVersionUID = -8722293800195731463L;
/**
@ -481,6 +482,7 @@ public final class ThaiBuddhistDate
* @param s the stream to read
* @throws InvalidObjectException always
*/
@java.io.Serial
private void readObject(ObjectInputStream s) throws InvalidObjectException {
throw new InvalidObjectException("Deserialization via serialization delegate");
}
@ -498,6 +500,7 @@ public final class ThaiBuddhistDate
*
* @return the instance of {@code Ser}, not null
*/
@java.io.Serial
private Object writeReplace() {
return new Ser(Ser.THAIBUDDHIST_DATE_TYPE, this);
}