diff options
author | mkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-01-07 11:32:07 +0000 |
---|---|---|
committer | mkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-01-07 11:32:07 +0000 |
commit | 2d95c02be6e1f4db30a38b0e9322df01445b132a (patch) | |
tree | be94893c552db65c2384cd29222e07c02378c21c /libjava/jni.cc | |
parent | fbbb20675404f3928d783d6655e432fd05933828 (diff) | |
download | gcc-2d95c02be6e1f4db30a38b0e9322df01445b132a.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@93046 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/jni.cc')
-rw-r--r-- | libjava/jni.cc | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/libjava/jni.cc b/libjava/jni.cc index 6138334ebaf..2f4c3e4fc84 100644 --- a/libjava/jni.cc +++ b/libjava/jni.cc @@ -41,6 +41,7 @@ details. */ #include <java/lang/ThreadGroup.h> #include <java/lang/Thread.h> #include <java/lang/IllegalAccessError.h> +#include <java/nio/Buffer.h> #include <java/nio/DirectByteBufferImpl.h> #include <java/nio/DirectByteBufferImpl$ReadWrite.h> #include <java/util/IdentityHashMap.h> @@ -1733,16 +1734,22 @@ static void * JNICALL _Jv_JNI_GetDirectBufferAddress (JNIEnv *, jobject buffer) { using namespace java::nio; - DirectByteBufferImpl* bb = static_cast<DirectByteBufferImpl *> (buffer); - return reinterpret_cast<void *> (bb->address); + if (! _Jv_IsInstanceOf (buffer, &Buffer::class$)) + return NULL; + Buffer *tmp = static_cast<Buffer *> (buffer); + return reinterpret_cast<void *> (tmp->address); } static jlong JNICALL _Jv_JNI_GetDirectBufferCapacity (JNIEnv *, jobject buffer) { using namespace java::nio; - DirectByteBufferImpl* bb = static_cast<DirectByteBufferImpl *> (buffer); - return bb->capacity(); + if (! _Jv_IsInstanceOf (buffer, &Buffer::class$)) + return -1; + Buffer *tmp = static_cast<Buffer *> (buffer); + if (tmp->address == NULL) + return -1; + return tmp->capacity(); } |