Skip to content

Commit

Permalink
8229997: Apply java.io.Serial annotations in java.base
Browse files Browse the repository at this point in the history
Reviewed-by: alanb, rriggs
  • Loading branch information
jddarcy committed Aug 29, 2019
1 parent 6d064a7 commit 9d764ee
Show file tree
Hide file tree
Showing 315 changed files with 880 additions and 254 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2013, 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
Expand Down Expand Up @@ -716,6 +716,7 @@ public String layoutForClassVersion(Package.Version vers) {

public static
class FormatException extends IOException {
@java.io.Serial
private static final long serialVersionUID = -2542243830788066513L;

private int ctype;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 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
Expand Down Expand Up @@ -605,6 +605,7 @@ void readInnerClasses(Class cls) throws IOException {
}

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

public ClassFormatException(String message) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 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
Expand Down Expand Up @@ -679,6 +679,7 @@ public static void opcodeChecker(byte[] code, ConstantPool.Entry[] cpMap,
}
}
static class FormatException extends IOException {
@java.io.Serial
private static final long serialVersionUID = 3175572275651367015L;

FormatException(String message) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2008, 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
Expand Down Expand Up @@ -33,6 +33,7 @@
public class CharConversionException
extends java.io.IOException
{
@java.io.Serial
private static final long serialVersionUID = -8680016352018427031L;

/**
Expand Down
3 changes: 2 additions & 1 deletion src/java.base/share/classes/java/io/EOFException.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 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
Expand Down Expand Up @@ -40,6 +40,7 @@
*/
public
class EOFException extends IOException {
@java.io.Serial
private static final long serialVersionUID = 6433858223774886977L;

/**
Expand Down
3 changes: 3 additions & 0 deletions src/java.base/share/classes/java/io/File.java
Original file line number Diff line number Diff line change
Expand Up @@ -2217,6 +2217,7 @@ public String toString() {
*
* @serialData Default fields followed by separator character.
*/
@java.io.Serial
private synchronized void writeObject(java.io.ObjectOutputStream s)
throws IOException
{
Expand All @@ -2230,6 +2231,7 @@ private synchronized void writeObject(java.io.ObjectOutputStream s)
* than the separator character on this system, then the old separator
* is replaced by the local separator.
*/
@java.io.Serial
private synchronized void readObject(java.io.ObjectInputStream s)
throws IOException, ClassNotFoundException
{
Expand All @@ -2251,6 +2253,7 @@ private synchronized void readObject(java.io.ObjectInputStream s)
= UNSAFE.objectFieldOffset(File.class, "prefixLength");

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

// -- Integration with java.nio.file --
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 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
Expand Down Expand Up @@ -41,6 +41,7 @@
*/

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

/**
Expand Down
7 changes: 7 additions & 0 deletions src/java.base/share/classes/java/io/FilePermission.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ public final class FilePermission extends Permission implements Serializable {
// return sb.toString();
// }

@java.io.Serial
private static final long serialVersionUID = 7930732926638008763L;

/**
Expand Down Expand Up @@ -1040,6 +1041,7 @@ public PermissionCollection newPermissionCollection() {
* to a stream. The actions are serialized, and the superclass
* takes care of the name.
*/
@java.io.Serial
private void writeObject(ObjectOutputStream s)
throws IOException
{
Expand All @@ -1054,6 +1056,7 @@ private void writeObject(ObjectOutputStream s)
* readObject is called to restore the state of the FilePermission from
* a stream.
*/
@java.io.Serial
private void readObject(ObjectInputStream s)
throws IOException, ClassNotFoundException
{
Expand Down Expand Up @@ -1210,6 +1213,7 @@ public Enumeration<Permission> elements() {
return perms.elements();
}

@java.io.Serial
private static final long serialVersionUID = 2202956749081564585L;

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

Expand All @@ -1245,6 +1251,7 @@ private void writeObject(ObjectOutputStream out) throws IOException {
/*
* Reads in a Vector of FilePermissions and saves them in the perms field.
*/
@java.io.Serial
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException
{
Expand Down
3 changes: 2 additions & 1 deletion src/java.base/share/classes/java/io/IOError.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 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
Expand Down Expand Up @@ -46,5 +46,6 @@ public IOError(Throwable cause) {
super(cause);
}

@java.io.Serial
private static final long serialVersionUID = 67100927991680413L;
}
3 changes: 2 additions & 1 deletion src/java.base/share/classes/java/io/IOException.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 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
Expand Down Expand Up @@ -37,6 +37,7 @@
*/
public
class IOException extends Exception {
@java.io.Serial
static final long serialVersionUID = 7818375828146090155L;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 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
Expand Down Expand Up @@ -41,6 +41,7 @@
*/
public
class InterruptedIOException extends IOException {
@java.io.Serial
private static final long serialVersionUID = 4020568460727500567L;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2006, 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
Expand Down Expand Up @@ -40,6 +40,7 @@
*/
public class InvalidClassException extends ObjectStreamException {

@java.io.Serial
private static final long serialVersionUID = -4333316296251054416L;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2005, 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
Expand Down Expand Up @@ -37,6 +37,7 @@
*/
public class InvalidObjectException extends ObjectStreamException {

@java.io.Serial
private static final long serialVersionUID = 3233174318281839583L;

/**
Expand Down
3 changes: 2 additions & 1 deletion src/java.base/share/classes/java/io/NotActiveException.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2005, 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
Expand Down Expand Up @@ -33,6 +33,7 @@
*/
public class NotActiveException extends ObjectStreamException {

@java.io.Serial
private static final long serialVersionUID = -3893467273049808895L;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2005, 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
Expand Down Expand Up @@ -35,6 +35,7 @@
*/
public class NotSerializableException extends ObjectStreamException {

@java.io.Serial
private static final long serialVersionUID = 2906642554793891381L;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/java.base/share/classes/java/io/ObjectStreamClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ public class ObjectStreamClass implements Serializable {
public static final ObjectStreamField[] NO_FIELDS =
new ObjectStreamField[0];

@java.io.Serial
private static final long serialVersionUID = -6120832682080437368L;
@java.io.Serial
private static final ObjectStreamField[] serialPersistentFields =
NO_FIELDS;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2005, 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
Expand Down Expand Up @@ -33,6 +33,7 @@
*/
public abstract class ObjectStreamException extends IOException {

@java.io.Serial
private static final long serialVersionUID = 7260898174833392607L;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2005, 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
Expand Down Expand Up @@ -47,6 +47,7 @@
*/
public class OptionalDataException extends ObjectStreamException {

@java.io.Serial
private static final long serialVersionUID = -8011121865681257820L;

/*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
Expand Down Expand Up @@ -101,6 +101,7 @@

public final class SerializablePermission extends BasicPermission {

@java.io.Serial
private static final long serialVersionUID = 8537212141160296410L;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2005, 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
Expand Down Expand Up @@ -34,6 +34,7 @@
*/
public class StreamCorruptedException extends ObjectStreamException {

@java.io.Serial
private static final long serialVersionUID = 8983558202217591746L;

/**
Expand Down
3 changes: 2 additions & 1 deletion src/java.base/share/classes/java/io/SyncFailedException.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2008, 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
Expand Down Expand Up @@ -34,6 +34,7 @@
* @since 1.1
*/
public class SyncFailedException extends IOException {
@java.io.Serial
private static final long serialVersionUID = -2353342684412443330L;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 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
Expand Down Expand Up @@ -44,6 +44,7 @@
*/
public
class UTFDataFormatException extends IOException {
@java.io.Serial
private static final long serialVersionUID = 420743449228280612L;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2013, 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
Expand Down Expand Up @@ -32,6 +32,7 @@
* @since 1.8
*/
public class UncheckedIOException extends RuntimeException {
@java.io.Serial
private static final long serialVersionUID = -8134305061645241065L;

/**
Expand Down Expand Up @@ -79,6 +80,7 @@ public IOException getCause() {
* if the object is invalid or has a cause that is not
* an {@code IOException}
*/
@java.io.Serial
private void readObject(ObjectInputStream s)
throws IOException, ClassNotFoundException
{
Expand Down
Loading

0 comments on commit 9d764ee

Please sign in to comment.