Class JavaSerializationCopier
java.lang.Object
com.github.benmanes.caffeine.jcache.copy.AbstractCopier<byte[]>
com.github.benmanes.caffeine.jcache.copy.JavaSerializationCopier
- All Implemented Interfaces:
Copier
A strategy that uses Java serialization if a fast path approach is not applicable.
Beware that Java serialization is slow, can be insecure, and is provided due to being required
by JSR-107. In practice, it is recommended that a higher performance alternative is used, which
is provided by numerous external libraries. If serialization must be used then consider supplying
an ObjectInputFilter or enabling
Serialization Filtering to restrict the classes that can be deserialized.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classAn ObjectInputStream that instantiates using the supplied classloader. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Objectdeserialize(byte[] data, ClassLoader classLoader) Deserializes the data using the provided classloader.protected byte[]Serializes the object.Methods inherited from class AbstractCopier
canDeeplyCopy, copy, isImmutable, javaDeepCopyStrategies, javaImmutableClasses, roundtrip
-
Constructor Details
-
JavaSerializationCopier
public JavaSerializationCopier() -
JavaSerializationCopier
-
JavaSerializationCopier
-
-
Method Details
-
serialize
Description copied from class:AbstractCopierSerializes the object.- Specified by:
serializein classAbstractCopier<byte[]>- Parameters:
object- the object to serialize- Returns:
- the serialized bytes
-
deserialize
Description copied from class:AbstractCopierDeserializes the data using the provided classloader.- Specified by:
deserializein classAbstractCopier<byte[]>- Parameters:
data- the serialized bytesclassLoader- the classloader to create the instance with- Returns:
- the deserialized object
-