ObjectInputStream: add rudimentary support for objects

This is by no means a complete support for the deserialization compliant
to the Java Language Specification, but it is better to add the support
incrementally, for better readability of the commits.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Test the new, Java-compatible (de)serialization

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
ObjectInputStream: handle fields of type String

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Fix java.lang.reflect.Field.getLong()

The bug was that the long was cast to an int, cutting off the most
significant bytes.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
ObjectOutputStream: optimize String serialization

The serialization protocol specifies a quick method to serialize
a String (because that is so common an operation): TC_STRING +
(short)length + bytes. Let's use that, also to make it easier to test
the upcoming changes to TreeMap harmonizing that Avian's serialization
of said class with OpenJDK's.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
ObjectOutputStream: use private writeObject() methods

The specification of the Java serialization demands that a private
writeObject(ObjectOutputStream) method is used -- if it exists. In that
case, ObjectOutputStream must not write the contents of the fields
(called 'classdata[]' in the documentation) but offer that via the
defaultWriteObject() method.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
ObjectInputStream: use private readObject() methods

The specification of the Java deserialization demands that a private
readObject(ObjectOutputStream) method is used -- if it exists. In
that case, ObjectInputStream must not initialize the contents of the
fields (called 'classdata[]' in the documentation) but offer that
functionality via the defaultReadObject() method.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Add a 'comparator' field to TreeMap

This will be needed for Java-compatible serialization of tree maps.

Note that the field should be null when the TreeMap uses the default
comparator.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Make TreeMap (de)serialization compatible with Java

This is done by implementing the readObject()/writeObject() method
pair as demanded by the serialization specification. The specifics
were reverse-engineered from serializing trivial TreeMap instances
with OpenJDK.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Serialize test: augment the hexdump with address and ASCII dump

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Add a test to ensure TreeMap's (de)serialization compatibility with OpenJDK

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Add a minimal FilterInputStream

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Add a hex-dumping FilterInputStream for debugging

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Mark java.lang.Number as serializable

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Make ArrayList's serialization compatible with OpenJDK's

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
ObjectInputStream: refactor class desc parsing

We punted previously on any serializable super class' descriptor and
simply expected the super class not to be serializable (and consequently,
we expected the respective descriptor to be null).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
ObjectInputStream: handle TC_REFERENCE

There are serialized objects out in the wild which make heavy use of
TC_REFERENCE: for example when an object has a reference to itself.

Therefore we need to support that, too.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
ObjectInputStream: handle super class descriptors correctly

We punted previously on any serializable super class' descriptor and
simply expected the super class not to be serializable (and consequently,
we expected the respective descriptor to be null). However, for quite
common classes, e.g. OpenJDK's Double class, this is not true.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
wip