Null-terminated Unicode strings in java.io on Windows
rob.lougher at gmail.com
Fri Jan 25 19:54:33 UTC 2008
On 1/25/08, Clemens Eisserer <linuxhippy at gmail.com> wrote:
> Hi there,
> > This is getting a bit hostile for no reason.... Thinking about
> > alignment gives an interesting solution.
> > 1) Strings are not null-terminated
> > 2) For most strings the alignment gives the VM room to terminate in
> > place when GetStringChars is called
> > 3) Copy strings that can't be terminated in place.
> However GetStringChars() as far as I know always returns a copy
> because hotspot does not support pinning (or at least I think so) - at
> least for the moving GCs. So if one byte more is allocated or not on
> the JNI side should not make much difference even if its never needed.
Yes, I already mentioned Sun probably chose to copy to avoid pinning.
I did the opposite in JamVM and pinned the String to avoid the copy.
It appears that other VMs such as gcj and Jamaica also do not copy the
string in GetStringChars (however, I do not know if they have a moving
GC or not).
The above was a solution to the problem of null-terminating the string
chars without having to copy.
> lg Clemens
More information about the core-libs-dev