From d2ba8a75ef0a2bbc078df1a101235a05b6e70787 Mon Sep 17 00:00:00 2001 From: Michael Koch Date: Fri, 7 Jan 2005 11:32:07 +0000 Subject: re PR libgcj/18115 (JNI nio buffer functions only work with byte buffers) 2005-01-07 Michael Koch 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 --- libjava/testsuite/libjava.jni/bytebuffer.java | 38 +++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 libjava/testsuite/libjava.jni/bytebuffer.java (limited to 'libjava/testsuite/libjava.jni/bytebuffer.java') diff --git a/libjava/testsuite/libjava.jni/bytebuffer.java b/libjava/testsuite/libjava.jni/bytebuffer.java new file mode 100644 index 0000000..0e54112 --- /dev/null +++ b/libjava/testsuite/libjava.jni/bytebuffer.java @@ -0,0 +1,38 @@ +// Test to make sure JNI implementation catches exceptions. + +import java.nio.*; + +public class bytebuffer +{ + static + { + System.loadLibrary("bytebuffer"); + } + + public static native void testByteBuffer(ByteBuffer bb); + public static native void testCharBuffer(CharBuffer b); + public static native void testDoubleBuffer(DoubleBuffer b); + public static native void testFloatBuffer(FloatBuffer b); + public static native void testIntBuffer(IntBuffer b); + public static native void testLongBuffer(LongBuffer b); + public static native void testShortBuffer(ShortBuffer b); + + public static void main(String[] args) + { + ByteBuffer bb = ByteBuffer.allocate(1024); + testByteBuffer(bb); + testCharBuffer(bb.asCharBuffer()); + testDoubleBuffer(bb.asDoubleBuffer()); + testFloatBuffer(bb.asFloatBuffer()); + testIntBuffer(bb.asIntBuffer()); + testLongBuffer(bb.asLongBuffer()); + testShortBuffer(bb.asShortBuffer()); + + testCharBuffer(CharBuffer.allocate(1024)); + testDoubleBuffer(DoubleBuffer.allocate(1024)); + testFloatBuffer(FloatBuffer.allocate(1024)); + testIntBuffer(IntBuffer.allocate(1024)); + testLongBuffer(LongBuffer.allocate(1024)); + testShortBuffer(ShortBuffer.allocate(1024)); + } +} -- cgit v1.1