[id='using-java-serialization_{context}']
= Using Java serialization
You can use Java serialization with {brandname} to marshall objects that implement the Java `Serializable` interface.

[TIP]
====
Java serialization offers worse performance than ProtoStream marshalling.
You should use Java serialization only if there is a strict requirement to do so.
====

.Procedure

. Configure {brandname} to use `JavaSerializationMarshaller`.
. Add your Java classes to the deserialization allowlist.

.Declarative
[source,xml,options="nowrap",subs=attributes+,role="primary"]
----
include::xml/serialization_marshaller.xml[]
----

.Programmatic
[source,java,options="nowrap",subs=attributes+,role="secondary"]
----
include::code_examples/SerializationMarshaller.java[]
----

[role="_additional-resources"]
.Additional resources
* link:{jdkdocroot}/java/io/Serializable.html[Serializable]
* link:{javadocroot}/org/infinispan/commons/marshall/JavaSerializationMarshaller.html[org.infinispan.commons.marshall.JavaSerializationMarshaller]
