aboutsummaryrefslogtreecommitdiff
path: root/libjava/jni.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/jni.cc')
-rw-r--r--libjava/jni.cc15
1 files changed, 11 insertions, 4 deletions
diff --git a/libjava/jni.cc b/libjava/jni.cc
index 6138334..2f4c3e4 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();
}