/* src/native/jni.cpp - implementation of the Java Native Interface functions
- Copyright (C) 1996-2005, 2006, 2007, 2008, 2009
+ Copyright (C) 1996-2012
CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
This file is part of CACAO.
if (cc == NULL)
c = load_class_from_sysloader(u);
- else
- c = load_class_from_classloader(u, cc->classloader);
+ else {
+ classloader_t *cl = cc->classloader;
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+ /* See jni_FindClass in Hotspot's src/share/vm/prims/jni.cpp */
+ if (!cl && cc->name == utf_java_lang_ClassLoader_NativeLibrary)
+ {
+ methodinfo *m = class_resolveclassmethod(
+ cc,
+ utf_new_char("getFromClass"),
+ utf_new_char("()Ljava/lang/Class;"),
+ NULL,
+ true);
+
+ java_handle_t *h;
+ if (m)
+ h = vm_call_method(m, NULL);
+
+ if (m && exceptions_get_exception() == NULL)
+ cl = ((classinfo *) LLNI_UNWRAP(h))->classloader;
+ else
+ return NULL;
+ }
+#endif
+ c = load_class_from_classloader(u, cl);
+ }
if (c == NULL) {
resolve_handle_pending_exception(true);
o = (java_handle_t *) obj;
- if ((o == NULL) || (LLNI_vftbl_direct(o) == NULL))
- return NULL;
-
LLNI_class_get(o, c);
java_handle_t* h = LLNI_classinfo_wrap(c);
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;
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");