Add additional checks in ObjectInputStream

Thanks to Jann Horn for reporting a bug in ObjectInputStream
and sending the initial patch.

Add some checks that the class of an object
being deserialized still conforms to the requirements
for serialization.

Add some checks that the class being deserialized matches
the type information (enum, serializable, externalizable)
held in the stream.

Delayed static initialization of classes until the
type of the class has been validated against the stream
content in some cases.

Added more tests.

Bug: 15874291
Change-Id: I0f0fe68e0d21e041c5160482113ae847c357b8f5
Add additional field checks for deserialization.

Check that a field is not static when deserializing.

Contains some additional tests to confirm and document behavior
and prevent regressions for field deserialization.

Bug: 17202597
Change-Id: I80fe0f1f15b36852de09320a4daa89333e753903
(cherry picked from commit f4d72bcf5a9caa1d6cac74a018ab68dd87ec6d83)