Back to Intellij Community

ReadObjectInitialization

java/java-impl/resources/inspectionDescriptions/ReadObjectInitialization.html

2025.3-rc-2523 B
Original Source

Reports fields that are not guaranteed to be initialized after the object is deserialized by the readObject() method.

The inspection doesn't report transient fields.

Note: This inspection uses a very conservative control flow algorithm, and may incorrectly report fields as uninitialized.

Example:

class DataObject implements Serializable {
  String s; // s is not initialized in readObject
  int i;

  private void readObject(ObjectInputStream stream) throws IOException {
    i = stream.readInt();
  }
}