This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: PATCH for java/nio buffers
- From: Michael Koch <konqueror at gmx dot de>
- To: Per Bothner <per at bothner dot com>
- Cc: gcc-patches at gcc dot gnu dot org, java-patches at gcc dot gnu dot org
- Date: Fri, 13 Feb 2004 09:50:50 +0100
- Subject: Re: PATCH for java/nio buffers
- References: <402C1489.1070806@bothner.com>
On Thu, Feb 12, 2004 at 04:04:25PM -0800, Per Bothner wrote:
> A second chunk of changes to java/nio buffer classes.
> These should hopefully be uncontroversial.
> Some are optimizations, some are bug-fixes.
> Tested on Fedora by running the libjava testsuite with Mauve,
> but not other tested for correctness.
As always: same dumb questions from my side of the ocean.
> 2004-02-12 Per Bothner <per@bothner.com>
>
> * java/nio/Buffer.java: Add default constructor.
Why is this needed ? Its not in the official API.
> * java/nio/ByteBuffer.java: Likewise.
Why is this needed ? Its not in the official API.
> * java/nio/ByteBuffer.java (endian): Make non-private so other
> java.nio classes can inherit it.
> (<init>): Don't bother clearing array_offset.
> * java/nio/ByteBuffer.java (allocate): Re-implement using wrap.
Can we remove the constructor used here in old code completely ?
> * java/nio/ByteBuffer.java (get(byte[],int,int)): Check underflow.
> Remove redundant test.
>
> * java/nio/ByteBufferImpl.java (asCharBuffer, asShortBuffer,
> asIntBuffer, asLongBuffer, asFloatBuffer, asDoubleBuffer):
> Use new XxxViewBufferImpl constructors.
> * java/nio/MappedByteBufferImpl.java: Likewise.
> * java/nio/DirectByteBufferImpl.java: Likewise.
>
> * java/nio/ByteBufferImpl.java (shiftDown): New optimized method.
>
> * java/nio/ByteBufferImpl.java (get, put): Add array_offset.
>
> * java/nio/CharBufferImpl.java: Inline super constructor.
> * java/nio/DoubleBufferImpl.java: Likewise.
> * java/nio/FloatBufferImpl.java: Likewise.
> * java/nio/IntBufferImpl.java: Likewise.
> * java/nio/LongBufferImpl.java: Likewise.
> * java/nio/ShortBufferImpl.java: Likewise.
> * java/nio/CharBuffer.java: Remove unused constructor.
> * java/nio/DoubleBuffer.java: Likewise.
> * java/nio/FloatBuffer.java: Likewise.
> * java/nio/IntBuffer.java: Likewise.
> * java/nio/LongBuffer.java: Likewise.
> * java/nio/ShortBuffer.java: Likewise.
> * java/nio/CharViewBufferImpl.java: New convenience constructor.
> Fix buggy call to super constructor.
> * java/nio/DoubleViewBufferImpl.java: Likewise.
> * java/nio/FloatViewBufferImpl.java: Likewise.
> * java/nio/IntViewBufferImpl.java: Likewise.
> * java/nio/LongViewBufferImpl.java: Likewise.
> * java/nio/ShortViewBufferImpl.java: Likewise.
>
> * java/nio/DirectByteBufferImpl.java (owner): New field.
> (offset): Remove unused field.
> (<init>): Modify one and add another constructor. Change callers.
> (allocateDirect): Rename to allocate - direct is implied by context.
No please don't. This violates the behaviour described for
ByteBuffer.allocate():
"The new buffer's position will be zero, its limit will be its capacity,
and its mark will be undefined. It will have a backing array, and its
array offset will be zero."
Direct buffers have no backing array. Sorry to come up so late with
this. I saw this in the original patch too.
> (getImpl, putImpl): Make static and pass address explicitly,
> to make them useful for MappedByteBufferImpl.
> (get, put): Check for underflow. Modify for new getImpl.
> (getImpl): New native method where target is array.
> (get(byte[],int,int)): Use the above.
> (adjustAddress): New static native method.
> (slice, duplicate, asReadOnly): New implementations.
> * java/nio/natDirectByteBufferImpl.cc (getImpl, putImpl, shiftDown,
> adjustAddress): New or updated native methods.
That are the things that felt into my eyes this morning. I just stood
up.
Michael