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>
Implement FilterReader

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

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>
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>
Merge pull request #94 from dscho/serialization

Implement Java-compatible serialization