Inspectopedia Help

'record' contains ignored members

Reports serialization methods or fields defined in a record class. Serialization methods include writeObject(), readObject(), readObjectNoData(), writeExternal(), and readExternal() and the field serialPersistentFields. These members are not used for the serialization or deserialization of records and therefore unnecessary.

Examples:

record R1() implements Serializable { // The field is ignored during record serialization @Serial private static final ObjectStreamField[] serialPersistentFields = new ObjectStreamField[0]; // The method is ignored during record serialization @Serial private void writeObject(ObjectOutputStream out) throws IOException { } }
record R2() implements Externalizable { // The method is ignored during record serialization @Override public void writeExternal(ObjectOutput out) throws IOException { } // The method is ignored during record serialization @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { } }

Locating this inspection

By ID

Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.

SerializableRecordContainsIgnoredMembers
Via Settings dialog

Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.

Settings or Preferences | Editor | Inspections | Java | Serialization issues

This inspection depends on the Java feature 'Records' which is available since Java 16.

New in 2020.3

Availability

By default bundled with

IntelliJ IDEA 2024.1, Qodana for JVM 2024.1,

Can be installed with plugin

Java, 241.18072

Last modified: 18 June 2024