Generics and ReadObject
问题 I have a simple server that uses generics and object serialization. (T is the input format, U is the output format). A simplified version that only deals with input is shown below: public class Server <T, U> implements Runnable { @override public void run () { try (ObjectInputStream inReader = new ObjectInputStream (this.connection.getInputStream ())) { T lastObj; while (true) { lastObj = (T) inReader.readObject (); System.out.println (lastObj.getClass ().getName ()); if (null != lastObj) {