Serialize a Java object to Java code?
问题 Is there an implementation that will serialize a Java object as Java code? For example, if I have the object Map<String,Integer> m = new Map<String,Integer>(); m.put("foo",new Integer(21)); I could serialize this using ObjectOutputStream out = new ObjectOutputStream( ... ); out.writeObject( m ); out.flush(); and the output would, for example, be java.util.Map<String,Integer> m = new java.util.Map<String,Integer>(); m.put("foo",new Integer(21)); Why would you want this? Sometimes it is easier