java.lang.String.getBytes(String enc) fixlet

Marco Trudel mtrudel@gmx.ch
Sat Mar 10 17:03:00 GMT 2007


This patch fixes a bug in GCJs java.lang.String.getBytes(String enc) and 
additionally cleans it up a little. This is the problem:

while (todo > 0 || converter->havePendingBytes())
{
   // We only really need to do a single write.
   converter->setFinished();
   int converted = converter->write(this, offset, todo, NULL);
}

Setting the converter to finished will only allow one succeeding write 
call. Doesn't make too much sense in a loop. So the patch repositions 
the flush (setFinished() + empty write()) to after the loop.
This makes java.lang.String.getBytes13 mauve test and 
"abc".getBytes("unicode") on Windows run without an 
IllegalStateException exception (since they will cycle multiple times 
through the loop).

- Compilation tested on a host=Linux target=Linux as well as host=Linux 
target=Mingw.
- java.lang.String.getBytes13 mauve test will now run correctly and 
report 3 failed calls to harness.check(). Without the patch, that test 
will end because of an exception. Otherwise no changes in the 
java.lang.String tests.

Changelog:
2007-??-??  Marco Trudel  <mtrudel@gmx.ch>

	* java/lang/natString.cc (getBytes (jstring enc)):
	Fixed the loop for multiple cycles, Code cleanup


Something I missed? Comments/Concerns?

Marco
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: natString.patch
URL: <http://gcc.gnu.org/pipermail/java-patches/attachments/20070310/b9913b6e/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: mauve_no_patch.txt
URL: <http://gcc.gnu.org/pipermail/java-patches/attachments/20070310/b9913b6e/attachment.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: mauve_with_patch.txt
URL: <http://gcc.gnu.org/pipermail/java-patches/attachments/20070310/b9913b6e/attachment-0001.txt>


More information about the Java-patches mailing list