re PR libgcj/18115 (JNI nio buffer functions only work with byte buffers)

2005-01-07  Michael Koch  <konqueror@gmx.de>

	PR libgcj/18115
	* java/nio/Buffer.java (address): New field.
	* java/nio/DirectByteBufferImpl.java (address): Removed.
	* java/nio/MappedByteBufferImpl.java (address): Likewise.
	* java/nio/CharViewBufferImpl.java (CharViewBufferImpl):
	Explicitly initialize Buffer.address if needed.
	* java/nio/DoubleViewBufferImpl.java (DoubleViewBufferImpl): Likewise.
	* java/nio/FloatViewBufferImpl.java (FloatViewBufferImpl): Likewise.
	* java/nio/IntViewBufferImpl.java (IntViewBufferImpl): Likewise.
	* java/nio/LongViewBufferImpl.java (LongViewBufferImpl): Likewise.
	* java/nio/ShortViewBufferImpl.java (ShortViewBufferImpl): Likewise.
	* jni.cc (_Jv_JNI_GetDirectBufferAddress): Don't assume buffer is a
	DirectByteBufferImpl object.
	(_Jv_JNI_GetDirectBufferCapacity): Likewise.
	* testsuite/libjava.jni/directbuffer.c,
	testsuite/libjava.jni/directbuffer.java,
	testsuite/libjava.jni/directbuffer.out,
	testsuite/libjava.jni/bytebuffer.c,
	testsuite/libjava.jni/bytebuffer.java,
	testsuite/libjava.jni/bytebuffer.out: New files.

From-SVN: r93046
This commit is contained in:
Michael Koch 2005-01-07 11:32:07 +00:00 committed by Michael Koch
parent 4600cc1427
commit d2ba8a75ef
17 changed files with 319 additions and 6 deletions

View file

@ -38,12 +38,18 @@ exception statement from your version. */
package java.nio;
import gnu.gcj.RawData;
/**
* @since 1.4
*/
public abstract class Buffer
{
int cap = 0;
int limit = 0;
int pos = 0;
int mark = -1;
RawData address;
/**
* Creates a new Buffer.

View file

@ -53,6 +53,8 @@ class CharViewBufferImpl extends CharBuffer
this.offset = bb.position();
this.readOnly = bb.isReadOnly();
this.endian = bb.order();
if (bb.isDirect())
this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
}
public CharViewBufferImpl (ByteBuffer bb, int offset, int capacity,
@ -64,6 +66,8 @@ class CharViewBufferImpl extends CharBuffer
this.offset = offset;
this.readOnly = readOnly;
this.endian = endian;
if (bb.isDirect())
this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
}
/**

View file

@ -55,7 +55,6 @@ abstract class DirectByteBufferImpl extends ByteBuffer
* memory and should free it.
*/
private final Object owner;
final RawData address;
final static class ReadOnly extends DirectByteBufferImpl
{

View file

@ -53,6 +53,8 @@ final class DoubleViewBufferImpl extends DoubleBuffer
this.offset = bb.position();
this.readOnly = bb.isReadOnly();
this.endian = bb.order();
if (bb.isDirect())
this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
}
public DoubleViewBufferImpl (ByteBuffer bb, int offset, int capacity,
@ -64,6 +66,8 @@ final class DoubleViewBufferImpl extends DoubleBuffer
this.offset = offset;
this.readOnly = readOnly;
this.endian = endian;
if (bb.isDirect())
this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
}
/**

View file

@ -53,6 +53,8 @@ final class FloatViewBufferImpl extends FloatBuffer
this.offset = bb.position();
this.readOnly = bb.isReadOnly();
this.endian = bb.order();
if (bb.isDirect())
this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
}
public FloatViewBufferImpl (ByteBuffer bb, int offset, int capacity,
@ -64,6 +66,8 @@ final class FloatViewBufferImpl extends FloatBuffer
this.offset = offset;
this.readOnly = readOnly;
this.endian = endian;
if (bb.isDirect())
this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
}
/**

View file

@ -53,6 +53,8 @@ final class IntViewBufferImpl extends IntBuffer
this.offset = bb.position();
this.readOnly = bb.isReadOnly();
this.endian = bb.order();
if (bb.isDirect())
this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
}
public IntViewBufferImpl (ByteBuffer bb, int offset, int capacity,
@ -64,6 +66,8 @@ final class IntViewBufferImpl extends IntBuffer
this.offset = offset;
this.readOnly = readOnly;
this.endian = endian;
if (bb.isDirect())
this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
}
/**

View file

@ -53,6 +53,8 @@ final class LongViewBufferImpl extends LongBuffer
this.offset = bb.position();
this.readOnly = bb.isReadOnly();
this.endian = bb.order();
if (bb.isDirect())
this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
}
public LongViewBufferImpl (ByteBuffer bb, int offset, int capacity,
@ -64,6 +66,8 @@ final class LongViewBufferImpl extends LongBuffer
this.offset = offset;
this.readOnly = readOnly;
this.endian = endian;
if (bb.isDirect())
this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
}
/**

View file

@ -45,7 +45,6 @@ import java.io.IOException;
final class MappedByteBufferImpl extends MappedByteBuffer
{
boolean readOnly;
RawData address;
/** Posix uses this for the pointer returned by mmap;
* Win32 uses it for the pointer returned by MapViewOfFile. */

View file

@ -53,6 +53,8 @@ final class ShortViewBufferImpl extends ShortBuffer
this.offset = bb.position();
this.readOnly = bb.isReadOnly();
this.endian = bb.order();
if (bb.isDirect())
this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
}
public ShortViewBufferImpl (ByteBuffer bb, int offset, int capacity,
@ -64,6 +66,8 @@ final class ShortViewBufferImpl extends ShortBuffer
this.offset = offset;
this.readOnly = readOnly;
this.endian = endian;
if (bb.isDirect())
this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
}
/**