X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=cacao.git;a=blobdiff_plain;f=src%2Fnative%2Fjni.cpp;h=661780662a239c07a46fd157f4ccce0377900621;hp=6e850fd2bac0db539175b06ad3fe7c06ea6b6b8a;hb=03349a3953e0f217d686d88b99fa176509a27559;hpb=f703b1265fbfb70a3de51067803b6b211d5c5d4d diff --git a/src/native/jni.cpp b/src/native/jni.cpp index 6e850fd2b..661780662 100644 --- a/src/native/jni.cpp +++ b/src/native/jni.cpp @@ -1,6 +1,6 @@ /* src/native/jni.cpp - implementation of the Java Native Interface functions - Copyright (C) 1996-2005, 2006, 2007, 2008, 2009 + Copyright (C) 1996-2011 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -3565,7 +3565,8 @@ void* jni_GetDirectBufferAddress(JNIEnv *env, jobject buf) jlong jni_GetDirectBufferCapacity(JNIEnv* env, jobject buf) { -#if defined(ENABLE_JAVASE) && defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) +#if defined(ENABLE_JAVASE) +# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) TRACEJNICALLS(("jni_GetDirectBufferCapacity(env=%p, buf=%p)", env, buf)); java_handle_t* h = (java_handle_t *) buf; @@ -3577,6 +3578,23 @@ jlong jni_GetDirectBufferCapacity(JNIEnv* env, jobject buf) jlong capacity = b.get_cap(); return capacity; +# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) + + TRACEJNICALLS(("jni_GetDirectBufferCapacity(env=%p, buf=%p)", env, buf)); + + java_nio_Buffer jnb(buf); + + if (!builtin_instanceof(jnb.get_handle(), class_sun_nio_ch_DirectBuffer)) + return -1; + + jlong capacity = jnb.get_capacity(); + + return capacity; + +# else +# error unknown classpath configuration +# endif + #else vm_abort("jni_GetDirectBufferCapacity: not implemented in this configuration");