Implement a Java-compatible ObjectOutputStream

The Java Language Specification documents the serialization protocol
implemented by this change set:

http://docs.oracle.com/javase/7/docs/platform/serialization/spec/protocol.html#10258

This change is intended to make it easier to use Avian VM as a drop-in
replacement for the Oracle JVM when serializing objects.

The previous serialization code is still available as
avian.LegacyObjectOutputStream.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Implement the Field#set<PrimitiveType> method family

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Make ObjectOutputStream's constants available to java.io

We will reuse the constants in the upcoming deserialization counterpart.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Implement a rudimentary Java-compatible ObjectInputStream

The Java Language Specification documents the serialization protocol
implemented by this change set:

http://docs.oracle.com/javase/7/docs/platform/serialization/spec/protocol.html#10258

This change is intended to make it easier to use Avian VM as a drop-in
replacement for the Oracle JVM when serializing objects.

The previous serialization code is still available as
avian.LegacyObjectInputStream.

This commit only implements the non-object parts of the deserialization
specification.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
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 TC_REFERENCE

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>
squash! ObjectInputStream: use private readObject() methods
OutputStream -> InputStream
wip