gcc/libjava/testsuite/libjava.jni/directbuffer.java
Michael Koch d2ba8a75ef 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
2005-01-07 11:32:07 +00:00

41 lines
1.2 KiB
Java

// Test to make sure JNI implementation catches exceptions.
import java.nio.*;
public class directbuffer
{
static
{
System.loadLibrary("directbuffer");
}
public static native ByteBuffer createDirectByteBuffer();
public static native void testDirectByteBuffer(ByteBuffer bb, int len);
public static native void testCharBuffer(CharBuffer b, int len);
public static native void testDoubleBuffer(DoubleBuffer b, int len);
public static native void testFloatBuffer(FloatBuffer b, int len);
public static native void testIntBuffer(IntBuffer b, int len);
public static native void testLongBuffer(LongBuffer b, int len);
public static native void testShortBuffer(ShortBuffer b, int len);
public static void main(String[] args)
{
ByteBuffer bb = createDirectByteBuffer();
CharBuffer cb = bb.asCharBuffer();
DoubleBuffer db = bb.asDoubleBuffer();
FloatBuffer fb = bb.asFloatBuffer();
IntBuffer ib = bb.asIntBuffer();
LongBuffer lb = bb.asLongBuffer();
ShortBuffer sb = bb.asShortBuffer();
testDirectByteBuffer(bb, 1024);
testCharBuffer(cb, 512);
testDoubleBuffer(db, 128);
testFloatBuffer(fb, 256);
testIntBuffer(ib, 256);
testLongBuffer(lb, 128);
testShortBuffer(sb, 512);
}
}