gcc/libjava/testsuite/libjava.jni/bytebuffer.c
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

63 lines
1.5 KiB
C

#include "bytebuffer.h"
static void
test_buffer (JNIEnv *env, jobject buffer, const char *name)
{
void *tmp = (*env)->GetDirectBufferAddress (env, buffer);
if (tmp == NULL)
printf ("PASS: address of %s\n", name);
else
printf ("FAIL: address of %s\n", name);
int tmplen = (*env)->GetDirectBufferCapacity (env, buffer);
if (tmplen == -1)
printf ("PASS: length of %s\n", name);
else
printf ("FAIL: length of %s\n", name);
}
JNIEXPORT void JNICALL
Java_bytebuffer_testByteBuffer (JNIEnv *env, jclass k, jobject buffer)
{
test_buffer (env, buffer, "java.nio.ByteBuffer");
}
JNIEXPORT void JNICALL
Java_bytebuffer_testCharBuffer (JNIEnv *env, jclass k, jobject buffer)
{
test_buffer (env, buffer, "java.nio.CharBuffer");
}
JNIEXPORT void JNICALL
Java_bytebuffer_testDoubleBuffer (JNIEnv *env, jclass k, jobject buffer)
{
test_buffer (env, buffer, "java.nio.DoubleBuffer");
}
JNIEXPORT void JNICALL
Java_bytebuffer_testFloatBuffer (JNIEnv *env, jclass k, jobject buffer)
{
test_buffer (env, buffer, "java.nio.FloatBuffer");
}
JNIEXPORT void JNICALL
Java_bytebuffer_testIntBuffer (JNIEnv *env, jclass k, jobject buffer)
{
test_buffer (env, buffer, "java.nio.IntBuffer");
}
JNIEXPORT void JNICALL
Java_bytebuffer_testLongBuffer (JNIEnv *env, jclass k, jobject buffer)
{
test_buffer (env, buffer, "java.nio.LongBuffer");
}
JNIEXPORT void JNICALL
Java_bytebuffer_testShortBuffer (JNIEnv *env, jclass k, jobject buffer)
{
test_buffer (env, buffer, "java.nio.ShortBuffer");
}