Probably with something like Class<T>.cast(deserializedBytes)? This might create issues with deserialized primitives though (you might get the object when you expect the primitive, then the cast will fail), so you'll probably need to handle those manually.