JDK-4126854 : Strings of 64K or larger cannot be marshalled due to DataOuptut.writeUTF() limit
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 1.2.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 1998-04-08
  • Updated: 1998-04-16
  • Resolved: 1998-04-16
Related Reports
Duplicate :  
Description
Strings cannot be serialized or marshalled if their UTF8 representation
will be 65536 bytes or larger in size.  This is a restriction imposed by
the 16-bit length field used by DataOutputStream.writeUTF(), and documented
there.

This might have been a DataOutputStream bug, but there's not much that can
be done there without breaking backwards compatibility, whereas we can workaround
it in serialization, probably.

Comments
WORK AROUND Translate Strings to byte[]s if they could get large.
11-06-2004

SUGGESTED FIX Make ObjectOutputStream break big strings into chunks before handing them to DataOutputStream. It looks like ObjectInputStream will happily reconstruct them (so long as only one object tag is assigned) in block mode.
11-06-2004

PUBLIC COMMENTS DataOutputStream.writeUTF has a documented restriction on the size of the length field (16 bits) which imposes a restriction on the size of the serialized String (64K).
10-06-2004