[id='marshalled-object-encoding_{context}']
= Marshalled Java objects
{brandname} stores marshalled Java objects in caches as byte arrays.
For example, the following is a simple representation of a `Person` object stored as a value in memory:

[source,text,options="nowrap",subs=attributes+]
----
value=[61 6c 61 6e 0a 70 61 72 74 72 69 64 67 65]
----

To store marshalled objects in caches, you should use the ProtoStream marshaller unless a strict requirement exists.
For example, when migrating client applications from older versions of {brandname}, you might need to temporarily use JBoss marshalling with your Hot Rod Java clients.

{brandname} stores marshalled Java objects as byte arrays with the following media types:

* `application/x-protostream`
* `application/x-jboss-marshalling`
* `application/x-java-serialized-object`

[NOTE]
====
When storing unmarshalled Java objects, {brandname} uses the object implementation of `equals()` and `hashCode()`.
When storing marshalled objects, the marshalled bytes are compared for equality and hashed instead.
====
