Skip to content

Commit 9d764ee

Browse files
committed
8229997: Apply java.io.Serial annotations in java.base
Reviewed-by: alanb, rriggs
1 parent 6d064a7 commit 9d764ee

315 files changed

Lines changed: 880 additions & 254 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/java.base/share/classes/com/sun/java/util/jar/pack/Attribute.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -716,6 +716,7 @@ public String layoutForClassVersion(Package.Version vers) {
716716

717717
public static
718718
class FormatException extends IOException {
719+
@java.io.Serial
719720
private static final long serialVersionUID = -2542243830788066513L;
720721

721722
private int ctype;

src/java.base/share/classes/com/sun/java/util/jar/pack/ClassReader.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -605,6 +605,7 @@ void readInnerClasses(Class cls) throws IOException {
605605
}
606606

607607
static class ClassFormatException extends IOException {
608+
@java.io.Serial
608609
private static final long serialVersionUID = -3564121733989501833L;
609610

610611
public ClassFormatException(String message) {

src/java.base/share/classes/com/sun/java/util/jar/pack/Instruction.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -679,6 +679,7 @@ public static void opcodeChecker(byte[] code, ConstantPool.Entry[] cpMap,
679679
}
680680
}
681681
static class FormatException extends IOException {
682+
@java.io.Serial
682683
private static final long serialVersionUID = 3175572275651367015L;
683684

684685
FormatException(String message) {

src/java.base/share/classes/java/io/CharConversionException.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1996, 2008, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -33,6 +33,7 @@
3333
public class CharConversionException
3434
extends java.io.IOException
3535
{
36+
@java.io.Serial
3637
private static final long serialVersionUID = -8680016352018427031L;
3738

3839
/**

src/java.base/share/classes/java/io/EOFException.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1995, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -40,6 +40,7 @@
4040
*/
4141
public
4242
class EOFException extends IOException {
43+
@java.io.Serial
4344
private static final long serialVersionUID = 6433858223774886977L;
4445

4546
/**

src/java.base/share/classes/java/io/File.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2217,6 +2217,7 @@ public String toString() {
22172217
*
22182218
* @serialData Default fields followed by separator character.
22192219
*/
2220+
@java.io.Serial
22202221
private synchronized void writeObject(java.io.ObjectOutputStream s)
22212222
throws IOException
22222223
{
@@ -2230,6 +2231,7 @@ private synchronized void writeObject(java.io.ObjectOutputStream s)
22302231
* than the separator character on this system, then the old separator
22312232
* is replaced by the local separator.
22322233
*/
2234+
@java.io.Serial
22332235
private synchronized void readObject(java.io.ObjectInputStream s)
22342236
throws IOException, ClassNotFoundException
22352237
{
@@ -2251,6 +2253,7 @@ private synchronized void readObject(java.io.ObjectInputStream s)
22512253
= UNSAFE.objectFieldOffset(File.class, "prefixLength");
22522254

22532255
/** use serialVersionUID from JDK 1.0.2 for interoperability */
2256+
@java.io.Serial
22542257
private static final long serialVersionUID = 301077366599181567L;
22552258

22562259
// -- Integration with java.nio.file --

src/java.base/share/classes/java/io/FileNotFoundException.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1994, 2008, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1994, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -41,6 +41,7 @@
4141
*/
4242

4343
public class FileNotFoundException extends IOException {
44+
@java.io.Serial
4445
private static final long serialVersionUID = -897856973823710492L;
4546

4647
/**

src/java.base/share/classes/java/io/FilePermission.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ public final class FilePermission extends Permission implements Serializable {
195195
// return sb.toString();
196196
// }
197197

198+
@java.io.Serial
198199
private static final long serialVersionUID = 7930732926638008763L;
199200

200201
/**
@@ -1040,6 +1041,7 @@ public PermissionCollection newPermissionCollection() {
10401041
* to a stream. The actions are serialized, and the superclass
10411042
* takes care of the name.
10421043
*/
1044+
@java.io.Serial
10431045
private void writeObject(ObjectOutputStream s)
10441046
throws IOException
10451047
{
@@ -1054,6 +1056,7 @@ private void writeObject(ObjectOutputStream s)
10541056
* readObject is called to restore the state of the FilePermission from
10551057
* a stream.
10561058
*/
1059+
@java.io.Serial
10571060
private void readObject(ObjectInputStream s)
10581061
throws IOException, ClassNotFoundException
10591062
{
@@ -1210,6 +1213,7 @@ public Enumeration<Permission> elements() {
12101213
return perms.elements();
12111214
}
12121215

1216+
@java.io.Serial
12131217
private static final long serialVersionUID = 2202956749081564585L;
12141218

12151219
// Need to maintain serialization interoperability with earlier releases,
@@ -1220,6 +1224,7 @@ public Enumeration<Permission> elements() {
12201224
* @serialField permissions java.util.Vector
12211225
* A list of FilePermission objects.
12221226
*/
1227+
@java.io.Serial
12231228
private static final ObjectStreamField[] serialPersistentFields = {
12241229
new ObjectStreamField("permissions", Vector.class),
12251230
};
@@ -1231,6 +1236,7 @@ public Enumeration<Permission> elements() {
12311236
* Writes the contents of the perms field out as a Vector for
12321237
* serialization compatibility with earlier releases.
12331238
*/
1239+
@java.io.Serial
12341240
private void writeObject(ObjectOutputStream out) throws IOException {
12351241
// Don't call out.defaultWriteObject()
12361242

@@ -1245,6 +1251,7 @@ private void writeObject(ObjectOutputStream out) throws IOException {
12451251
/*
12461252
* Reads in a Vector of FilePermissions and saves them in the perms field.
12471253
*/
1254+
@java.io.Serial
12481255
private void readObject(ObjectInputStream in)
12491256
throws IOException, ClassNotFoundException
12501257
{

src/java.base/share/classes/java/io/IOError.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -46,5 +46,6 @@ public IOError(Throwable cause) {
4646
super(cause);
4747
}
4848

49+
@java.io.Serial
4950
private static final long serialVersionUID = 67100927991680413L;
5051
}

src/java.base/share/classes/java/io/IOException.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1994, 2006, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1994, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -37,6 +37,7 @@
3737
*/
3838
public
3939
class IOException extends Exception {
40+
@java.io.Serial
4041
static final long serialVersionUID = 7818375828146090155L;
4142

4243
/**

0 commit comments

Comments
 (0)