VMChannel.write(ByteBuffer src, int pos, int len) will return a wrong number of bytes written when (len=1).
When (len=1), the method calls Filesystem.writeByte(...) and considers the returned value as a number of bytes written. Problem is Filesystem.writeByte() returns an "OK" status (0 <=> one byte written, otherwise an error occurred). Thus the current implementation reports 0 byte written when the writeByte operation succeed.
The bug is located at libraryInterface/GNUClasspath/LGLP/src/gnu/java/nio/VMChannel.java:411
A possible fix:
change the following line
bytes = FileSystem.writeByte(nfd.getNativeFD(),src.get(pos));
by the following line
bytes = ( FileSystem.writeByte(nfd.getNativeFD(),src.get(pos)) == 0 ? 1 : 0 )
This solution however doesn't take care of a possible error status returned.
That is a common bug, even with Harmony lib.
some problem paste patch. Actually change "return 0" to "return rc"
Fix VMChannel.write(ByteBuffer,int,int) to report right number of bytes written when writing one byte and throw an IOException if FileSystem.writeByte failed.
Applied VMChannel.java.patch in 10409:0766fceb8b61.
Looked, but did not see similar problem in Harmony libraryInterface code.
Decided to not change meaning of sysWriteByte return code since it is called from more than just this one place.
bulk close of all resolved issues in preparation for 3.1.3 release.