[jdom-interest] Question about element length

Jason Hunter jhunter at collab.net
Wed Aug 23 09:45:11 PDT 2000


"Rosen, Alex" wrote:
> 
> > Regardless, I don't believe Java has a String length restriction.  I
> > just wrote a sample program that constructs a 1,000,000 character
> > string, and it worked fine.  Now I seem to recall method bodies have a
> > 64K restriction; maybe you're thinking of that.
> >
> > -jh-
> 
> Therefore, the
> serialized String is limited to 64K of UTF-8 bytes (not chars). 
> Which is a pretty nasty bug, 

Yes it is nasty.  We could theoretically work around the bug with
customized serialization logic in Element, but it'd take a lot of ugly
code.  Would have to make the content List transient and walk through it
piece by piece writing out each "node", and if the node was a string >
64K then it'd have to be broken into sub strings with those serialized. 
On read in you'd have to do the opposite.  Would also need some way to
represent what kind of List was serialized, so you could construct a new
list of the same type.

>I vaguely
> recall that they were somehow going to fix this for some JDK 
> release, but I don't remember which one.

That's the right way to fix it.  :-)

-jh-



More information about the jdom-interest mailing list