Persistent state property is not serialized
Reports a property of a persistent state class that the store does not save.
Write each setting in one of these two forms.
An immutable state. Keep the property read-only, and put a store annotation from
com.intellij.util.xmlb.annotationson the field, for example@Property,@OptionTag,@Attribute,@XCollection, or@XMap. Add@JvmFieldin Kotlin, so the annotation lands on the field. Use this form withSerializablePersistentStateComponentand adata class.A mutable state. Make the property public and mutable. Use
varin Kotlin, or a public non-final field in Java. The store binds such a property with no annotation. Use this form withBaseState.
Put a store annotation on the field, not on the getter. An annotation on a getter alone does not create a binding, because the store needs a setter to load the value back.
Choose the annotation by the type of the property. Use @XCollection for a collection and @XMap for a map, because each one states the shape of the XML. @Property fits every other type.
When the store must skip the property, mark it with @Transient from com.intellij.util.xmlb.annotations.
A property in any other form looks correct, but the store writes nothing for it. The property takes its default value again after each IDE restart, and the user loses the setting. The store gives no warning, so this defect stays hidden until a user reports the data loss.
Note: com.intellij.configurationStore.Property is a different annotation. It holds a description, and the store does not save a property because of it.
Example (Kotlin):
Example (Java):
The inspection accepts two more forms, because the rules above do not apply to them:
A read-only property of a class that carries
@kotlinx.serialization.Serializable.kotlinx.serializationreplaces the bean binding of such a class, and it saves a read-only property. Do not add this annotation to an existing state class only to keep a read-only property. It writes the state as JSON, so the store cannot read a settings file that a user already saved.A member that holds a dependency of the component, for example a
Project, aCoroutineScopeor aFlow. The store cannot write a value of such a type, so leave the member read-only.
The inspection reports only a member that the store can see. It does not report a Kotlin private var or protected var property.
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.
PersistentStatePropertyNotSerialized- 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.
New in 2026.3
Inspection ID: PersistentStatePropertyNotSerialized
Suppressing Inspection
You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:
More detailed instructions as well as other ways and options that you have can be found in the product documentation:
Inspection Details | |
|---|---|
By default bundled with: |