Class SerializableChecker

java.lang.Object
java.io.OutputStream
java.io.ObjectOutputStream
de.hybris.platform.util.SerializableChecker
All Implemented Interfaces:
Closeable, DataOutput, Flushable, ObjectOutput, ObjectStreamConstants, AutoCloseable

public final class SerializableChecker extends ObjectOutputStream
Utility class that analyzes objects for non-serializable nodes. Construct with the object you want to check, and then call check(Object obj). When a non-serializable object is found, a SerializableChecker.JaloNotSerializableException is thrown with a message that shows the trace up to the not-serializable object. The exception is thrown for the first non-serializable instance it encounters, so multiple problems will not be shown.

As this class depends heavily on JDK's serialization internals using introspection, analyzing may not be possible, for instance when the runtime environment does not have sufficient rights to set fields accesible that would otherwise be hidden. You should call isAvailable() to see whether this class can operate properly. If it doesn't, you should fall back to e.g. re-throwing/ printing the NotSerializableException you probably got before using this class.