Reports methods and fields in Serializable and Externalizable classes that are suitable to be annotated with the java.io.Serial annotation.

Examples:

class Test implements Serializable {
  // could be marked as @Serial
  private static final long serialVersionUID = 7874493593505141603L;

  // could be marked as @Serial
  private void writeObject(ObjectOutputStream out) throws IOException {
  }
}
class Test implements Externalizable {
  // could be marked as @Serial
  protected Object readResolve() throws ObjectStreamException {
    return "SomeObject";
  }
}

To get more information about all possible cases, refer the documentation for java.io.Serial.

This inspection only reports if the language level of the project or module is 14 or higher.

New in 2020.3