Hi,

java.nio.ByteBuffer#compact() must set the position to the
end of the moved bytes and the limit to the capacity.

But this method of kaffe's, that is GNU Classpath's,  does not do so
when the buffer is already compact.

Test program:

import java.nio.ByteBuffer;
public class TestByteBufferCompact {
    public static void main(String[] args) {
        ByteBuffer buffer = ByteBuffer.allocate(10);
        buffer.position(0);
        buffer.limit(3);
        buffer.compact();
        System.out.println("position=" + buffer.position() +
            " limit=" + buffer.limit());
    }
}

Run it with Sun's java:

bash$ java TestByteBufferCompact     
position=3 limit=10

Run it with Kaffe:

bash$ kaffe TestByteBufferCompact     
position=0 limit=3

Patch:

--- java/nio/ByteBufferImpl.java.orig   Wed Jun 16 02:39:09 2004
+++ java/nio/ByteBufferImpl.java        Wed Dec 29 13:45:52 2004
@@ -120,6 +120,11 @@
        position(count);
        limit(capacity());
       }
+    else
+      {
+        position(limit());
+        limit(capacity());
+      }
     return this;
   }
   

_______________________________________________
kaffe mailing list
[email protected]
http://kaffe.org/cgi-bin/mailman/listinfo/kaffe

Reply via email to