Is it possible to searialize/desearialize anonymous class in Java?
Example:
ByteArrayOutputStream operationByteArrayStream = new ByteArrayOutputStrea
This is certainly possible. Java generates an internal name for anonymous classes (Similar to DeclaredInThisClass$1, DeclaredInThisClass$2 if you declare them in a class called DeclaredInThisClass) and will happily serialize/deserialize them.
Sure! In your case class Task should implement the Serializable interface.
Note that in addition to Task implementing Serializable, the outer class must also be Serializable. You may end up serializing unnecessary member states.
It is possible, by dangerous. The name/number of anonymous classes is generated by the compiler and is based on the order they appear in the file. e.g. if you swap the order of two classes, their names will swap as well. (Classes are deserialized by name)