Removing the nestedException field from ObjectOutputStream.

The creation of the StreamCorruptedException in the constructor adds expense.
A common usage of ObjectOutputStream in Android is to write Serializable
objects into a Parcel, which uses a ByteArrayOutputStream and should never fail
with an IOException. This change should provide a small speed up and reduce
memory usage for the common case.

StreamCorruptedException is intended for use when reading from an ObjectStream
and it is no longer used. Also, by throwing a new exception the root cause
(either the original failure, or of the failure to write the exception to the
output stream) is obscured. Of the two possible exceptions that could be thrown
it seems best to throw the original and swallow the second. Added documentation.
Small risk of externally visible changes if callers are depending on the exact
class of the exception thrown but the use of StreamCorruptedException is not
documented and is unlikely to break anybody.

Also tidying up other simple code problems:
1) Unused parameter on writeEnumDesc()
2) Removing the getFieldL native method. It is never called and does not appear
to be backed by any native code.
3) Removing unnecessary initialization of local variables.

bug: 6447733
Change-Id: If062aa8d376019ed0c8db969e8161f18898e64e5
1 file changed