### Question:
Hessian2Output extends AbstractHessianOutput implements Hessian2Constants { @Override public void writeObject(Object object) throws IOException { if (object == null) { writeNull(); return; } Serializer serializer = findSerializerFactory().getObjectSerializer(object.getClass()); serializer.writeObject(object, this); } Hessian2Output();  Hessian2Output(OutputStream os); @Override void init(OutputStream os); void initPacket(OutputStream os); void setCloseStreamOnClose(boolean isClose); boolean isCloseStreamOnClose(); @Override boolean setUnshared(boolean isUnshared); @Override void call(String method, Object[] args); @Override void startCall(String method, int length); @Override void startCall(); void startEnvelope(String method); void completeEnvelope(); void writeMethod(String method); @Override void completeCall(); @Override void startReply(); void writeVersion(); @Override void completeReply(); void startMessage(); void completeMessage(); void writeFault(String code, String message, Object detail); @Override void writeObject(Object object); boolean writeListBegin(int length, String type); void writeListEnd(); void writeMapBegin(String type); void writeMapEnd(); @Override int writeObjectBegin(String type); @Override void writeClassFieldLength(int len); @Override void writeObjectEnd(); @Override void writeBoolean(boolean value); @Override void writeInt(int value); void writeLong(long value); void writeDouble(double value); void writeUTCDate(long time); void writeNull(); void writeString(String value); void writeString(char[] buffer, int offset, int length); void writeBytes(byte[] buffer); void writeBytes(byte[] buffer, int offset, int length); void writeByteBufferStart(); void writeByteBufferPart(byte[] buffer, int offset, int length); void writeByteBufferEnd(byte[] buffer, int offset, int length); OutputStream getBytesOutputStream(); @Override void writeByteStream(InputStream is); @Override boolean addRef(Object object); @Override int getRef(Object obj); @Override boolean removeRef(Object obj); @Override boolean replaceRef(Object oldRef, Object newRef); void writeStreamingObject(Object obj); void startPacket(); void endPacket(); void printLenString(String v); void printString(String v); void printString(String v, int strOffset, int length); void printString(char[] v, int strOffset, int length); final void flush(); final void flushBuffer(); @Override void close(); void free(); @Override void resetReferences(); void reset(); final static int SIZE; }### Answer:
@Test public void writeObject() throws IOException { User user = new User(); user.setId(1); user.setName("JJ"); Clazz clazz = new Clazz(); clazz.setId(1); clazz.setName("2班"); user.setClazz(clazz); hessian2Output.writeObject(user); Person<User> userPerson = new Person<>(); userPerson.setA(user); userPerson.setId(1); hessian2Output.writeObject(userPerson); hessian2Output.flush(); byte[] data = bytesOutputStream.toByteArray(); hessian2Input = hessianFactory.createHessian2Input(new ByteArrayInputStream(data)); User user1 = (User) hessian2Input.readObject(User.class); System.out.println(user1); Person person = (Person) hessian2Input.readObject(Person.class); System.out.println(person); }