Is there an implementation that will serialize a Java object as Java code? For example, if I have the object
Map m = new Map
I implemented this functionality in a new github project. You can find the project here:
https://github.com/ManuelB/java-bean-to-code-serializer
The project does not have any external dependencies except junit.
Currently it is not supporting arrays for serialization yet. Nevertheless there is already a lot of functionalities:
Object2CodeObjectOutputStream object2CodeObjectOutputStream = new Object2CodeObjectOutputStream(
byteArrayOutputStream);
object2CodeObjectOutputStream.writeObject();
System.out.println(
byteArrayOutputStream.toString());