# Serializable PersistentStateComponent﻿ docs look to be wrong

**URL:** <https://platform.jetbrains.com/t/serializable-persistentstatecomponent-docs-look-to-be-wrong/1897>\
**Category:** IntelliJ Platform\
**Tags:** sdk-docs\
**Created:** [June 2, 2025, 4:54pm UTC](https://platform.jetbrains.com/t/serializable-persistentstatecomponent-docs-look-to-be-wrong/1897 "2025-06-02T16:54:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![abrooksv](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/abrooksv/32/924_2.png) [@abrooksv](https://platform.jetbrains.com/u/abrooksv)\
**Post date:** [June 2, 2025, 4:54pm UTC](https://platform.jetbrains.com/t/serializable-persistentstatecomponent-docs-look-to-be-wrong/1897/1 "2025-06-02T16:54:07Z")

</div>

The [docs](https://plugins.jetbrains.com/docs/intellij/persisting-state-of-components.html#SerializablePersistentStateComponent) for `SerializablePersistentStateComponent﻿` say you need to use `@JvmField`, but this does not work except for Maps and Collections: [code](https://github.com/JetBrains/intellij-community/blob/4d6a1d13e2783aeded216619f2d366a9aa70c7e0/platform/util/src/com/intellij/serialization/PropertyCollector.java#L261-L267)

In order for it to work, the field needs to be marked with a storage annotation such as `@field:Property` instead in order to trigger this [logic](https://github.com/JetBrains/intellij-community/blob/ead4c23bcd9ed1c846b63237399e19e6673458d7/platform/util/src/com/intellij/util/xmlb/BeanBinding.kt#L543-L555)

3rd party plugins can also not [leverage](https://github.com/JetBrains/intellij-community/blob/e4e575384632be91ebeea75cacb04086f747d92e/platform/object-serializer/src/xml/xmlSerializer.kt#L161-L163) kotlin-serializazation due to different classloaders make that statement return false, is this expected and tracked as an improvement to the platform?

---

<div class="post-metadata">

**Author:** ![yuriy.artamonov](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/yuriy.artamonov/32/48_2.png) [@yuriy.artamonov](https://platform.jetbrains.com/u/yuriy.artamonov)\
**Post date:** [February 21, 2026, 7:12pm UTC](https://platform.jetbrains.com/t/serializable-persistentstatecomponent-docs-look-to-be-wrong/1897/2 "2026-02-21T19:12:43Z")

</div>

Hi! We are trying to resolve some complexities at the moment, at least by dropping the need for `@JvmField`. I don’t think kotlinx-serializazation is a right solution as it is rather bad to have JSON in XML if settings are shared in Git.

---

<div class="post-metadata">

**Author:** ![abrooksv](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/abrooksv/32/924_2.png) [@abrooksv](https://platform.jetbrains.com/u/abrooksv)\
**Post date:** [February 23, 2026, 3:42pm UTC](https://platform.jetbrains.com/t/serializable-persistentstatecomponent-docs-look-to-be-wrong/1897/4 "2026-02-23T15:42:08Z")

</div>

+100 on that front.

Benefits of K-S though is that it is easy to test the serialization and adding custom serialization layers if needed. Wish there was a K-S XML serializer we could use with it.

I currently test the forwards/backwards compatibility of the serialization using these utils which is close but not exact to how the IDE does the serialization, (if you have a better way please let me know):

```auto
import com.intellij.configurationStore.deserializeAndLoadState
import com.intellij.configurationStore.serializeStateInto
import com.intellij.openapi.components.PersistentStateComponent
import com.intellij.openapi.components.State
import com.intellij.openapi.util.JDOMUtil
import com.intellij.util.toByteArray
import com.intellij.util.xmlb.Constants
import org.intellij.lang.annotations.Language
import org.jdom.Element

fun PersistentStateComponent<*>.serializeState(): String {
    val holder = Element("component")
    holder.setAttribute(Constants.NAME, this.getName())
    serializeStateInto(this, holder)
    return holder.toByteArray().decodeToString()
}

private fun <T> PersistentStateComponent<T>.getName(): String {
    return this::class.annotations.filterIsInstance<State>().single().name
}

fun PersistentStateComponent<*>.deserializeState(@Language("XML") str: String) {
    deserializeAndLoadState(this, JDOMUtil.load(str))
}

```
