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

@ -280,6 +280,7 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
private static final int MAX_COMPACT_DIGITS = 18;
/* Appease the serialization gods */
@java.io.Serial
private static final long serialVersionUID = 6108874887143696463L;
private static final ThreadLocal<StringBuilderHelper>
@ -4127,6 +4128,7 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
*
* @param s the stream being read.
*/
@java.io.Serial
private void readObject(java.io.ObjectInputStream s)
throws java.io.IOException, ClassNotFoundException {
// Read in all fields
@ -4145,6 +4147,7 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
*
* @param s the stream to serialize to.
*/
@java.io.Serial
private void writeObject(java.io.ObjectOutputStream s)
throws java.io.IOException {
// Must inflate to maintain compatible serial form.

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 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
@ -4604,6 +4604,7 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
}
/** use serialVersionUID from JDK 1.1. for interoperability */
@java.io.Serial
private static final long serialVersionUID = -8287574255936472291L;
/**
@ -4622,6 +4623,7 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
* @serialField lowestSetBit int
* appears in the serialized form for backward compatibility
*/
@java.io.Serial
private static final ObjectStreamField[] serialPersistentFields = {
new ObjectStreamField("signum", Integer.TYPE),
new ObjectStreamField("magnitude", byte[].class),
@ -4643,6 +4645,7 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
* be taken in readObject because those fields already have a 0 value by
* default since defaultReadObject is not being used.
*/
@java.io.Serial
private void readObject(java.io.ObjectInputStream s)
throws java.io.IOException, ClassNotFoundException {
// prepare to read the alternate persistent fields
@ -4709,6 +4712,7 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
* with older implementations, but will be ignored by current
* implementations.
*/
@java.io.Serial
private void writeObject(ObjectOutputStream s) throws IOException {
// set the values of the Serializable fields
ObjectOutputStream.PutField fields = s.putFields();

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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
@ -64,6 +64,7 @@ public final class MathContext implements Serializable {
private static final int MIN_DIGITS = 0;
// Serialization version
@java.io.Serial
private static final long serialVersionUID = 5579720004786848255L;
/* ----- Public Properties ----- */
@ -309,6 +310,7 @@ public final class MathContext implements Serializable {
*
* @param s the stream being read.
*/
@java.io.Serial
private void readObject(java.io.ObjectInputStream s)
throws java.io.IOException, ClassNotFoundException {
s.defaultReadObject(); // read in all fields