Null-terminated Unicode strings in on Windows

Alan Bateman Alan.Bateman at Sun.COM
Fri Jan 25 15:05:13 UTC 2008

Roman Kennke wrote:
> Hi Alan,
> Am Montag, den 21.01.2008, 21:52 +0000 schrieb Alan Bateman:
>> :
>> The GetStringChars implementation in HotSpot always returns a copy that 
>> is length+1 and zero terminated. There is a long-standing bug to clarify 
>> the JNI specification on this topic. I believe it should say that the 
>> returned array of Unicode characters is not required to be zero 
>> terminated and that one should use GetStringLength to determine the 
>> length. Steve Bohne (cc'ed) has done the recent maintenance on the JNI 
>> spec and may wish to comment. In any case, I did a quick cscope and 
>> aside from, it only appears to impact a small number of places.
> So this is indeed a bug, right? Do you think it makes sense to go out
> and fix it?
This is one of issues that has gone unnoticed for years because we don't 
test with other VMs and also the Windows code isn't used when porting to 
other platforms. So I'd suggest just doing it.  Mark Wielaard's mail 
provides a good suggestion. You'll probably want to check other areas of 
the code too (src/windows/native/java/lang/ProcessImpl_md.c for example) 
for other cases.


More information about the core-libs-dev mailing list