I get in my function message array of bytes and type of object, I need to restore object from bytes. Is there in Java any cast like in C++ ?
There is no way in Java to have an arbitrary block of bytes and then tell the compiler "you need to treat this as an object of type X".
How were those bytes that you want to "restore into an object" created in the first place?
Java has a serialization mechanism to convert objects to a stream of bytes and vice versa.