Class RemappingFilteringObjectInputStream

Object
InputStream
ObjectInputStream
RemappingFilteringObjectInputStream
All Implemented Interfaces:
Closeable, DataInput, ObjectInput, ObjectStreamConstants, AutoCloseable

public final class RemappingFilteringObjectInputStream extends ObjectInputStream
An ObjectInputStream that supports:
  • validation of class names (exact, primitive, regex) before deserialization;
  • remapping of class names (exact or package prefix) during deserialization; and
  • optionally replacing the stream's class descriptor with the local one when a class is remapped, avoiding InvalidClassException due to mismatched SUIDs.

The validation step is performed first, on the original class name from the stream. If validation fails, an InvalidClassException is thrown. If validation passes, remapping is applied (if any) and the (possibly remapped) class is loaded.

Array types are supported, including multidimensional arrays and arrays of primitives. Array types are validated and remapped based on their element type.

This class also supports chaining with a JEP 290 ObjectInputFilter for additional filtering.

This class is NOT thread-safe; use a separate instance per thread.