Our implementation of direct byte buffers has some bugs, two of which are fixed by this patch. I'll check in a Mauve test for these soon.
NIO in general is in dire need of some serious attention; I have a
feeling that these two nits are just the tip of the iceberg.
2006-08-06 C. Scott Marshall <[EMAIL PROTECTED]>
Fixes PR 28608.
* java/nio/DirectByteBufferImpl.java (duplicate): only reset if
the mark has been set.
* native/jni/java-nio/java_nio_VMDirectByteBuffer.c
(Java_java_nio_VMDirectByteBuffer_allocate): zero out the
allocated data.
Thanks.
Index: java/nio/DirectByteBufferImpl.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/DirectByteBufferImpl.java,v
retrieving revision 1.21
diff -u -B -b -r1.21 DirectByteBufferImpl.java
--- java/nio/DirectByteBufferImpl.java 3 Aug 2005 13:12:59 -0000 1.21
+++ java/nio/DirectByteBufferImpl.java 6 Aug 2006 20:45:48 -0000
@@ -232,6 +232,7 @@
private ByteBuffer duplicate(boolean readOnly)
{
int pos = position();
+ if (this.mark != -1)
reset();
int mark = position();
position(pos);
Index: native/jni/java-nio/java_nio_VMDirectByteBuffer.c
===================================================================
RCS file:
/cvsroot/classpath/classpath/native/jni/java-nio/java_nio_VMDirectByteBuffer.c,v
retrieving revision 1.14
diff -u -B -b -r1.14 java_nio_VMDirectByteBuffer.c
--- native/jni/java-nio/java_nio_VMDirectByteBuffer.c 25 Jan 2006 10:40:12
-0000 1.14
+++ native/jni/java-nio/java_nio_VMDirectByteBuffer.c 6 Aug 2006 20:45:48
-0000
@@ -60,6 +60,8 @@
return 0;
}
+ memset (buffer, 0, capacity);
+
return JCL_NewRawDataObject (env, buffer);
}
signature.asc
Description: OpenPGP digital signature
