Index: vm/vmcore/include/vm_threads.h =================================================================== --- vm/vmcore/include/vm_threads.h (revision 505214) +++ vm/vmcore/include/vm_threads.h (working copy) @@ -81,6 +81,11 @@ */ JNIEnv_Internal * jni_env; + /** + * Class loader which loads native library and calls to its JNI_OnLoad + */ + ClassLoader* onload_caller; + // In case exception is thrown, Exception object is put here // TODO: Needs to be replaced with jobject! //volatile ManagedObject* p_exception_object; @@ -133,8 +138,7 @@ //gc_enable_disable_state gc_enabled_status; bool gc_wait_for_enumeration; bool restore_context_after_gc_and_resume; - - + #if defined(PLATFORM_POSIX) && defined(_IPF_) // Linux/IPF sem_t suspend_sem; // To suspend thread in signal handler Index: vm/vmcore/src/jni/jni_utils.cpp =================================================================== --- vm/vmcore/src/jni/jni_utils.cpp (revision 505214) +++ vm/vmcore/src/jni/jni_utils.cpp (working copy) @@ -676,12 +676,14 @@ assert(hythread_is_suspend_enabled()); // Determine loader StackTraceFrame stf; - bool res = st_get_frame(0, &stf); - ClassLoader* loader; - if (res) - loader = (ClassLoader*)class_get_class_loader(method_get_class(stf.method)); - else - loader = env->vm->vm_env->system_class_loader; + ClassLoader* loader = p_TLS_vmthread->onload_caller; + if(loader == NULL) { + bool res = st_get_frame(0, &stf); + if (res) + loader = (ClassLoader*)class_get_class_loader(method_get_class(stf.method)); + else + loader = env->vm->vm_env->system_class_loader; + } String *s = name; Class* clss = class_load_verify_prepare_by_loader_jni(VM_Global_State::loader_env, s, loader); Index: vm/vmcore/src/class_support/classloader.cpp =================================================================== --- vm/vmcore/src/class_support/classloader.cpp (revision 505214) +++ vm/vmcore/src/class_support/classloader.cpp (working copy) @@ -968,16 +968,15 @@ apr_pool_t* tmp_pool; apr_status_t stat = apr_pool_create(&tmp_pool, this->pool); // FIXME: process failure properly - - // - // $$$ GMJ - we don't want it to be where we're running from, but - // where everything else came from. For now, let it be - // so that apr_dso_load() will do the right thing. This is - // going to be weird, because we have native code in both - // / as well as /default... FIXME - // - // const char* canoname = port_filepath_canonical(name, tmp_pool); + // $$$ GMJ - we don't want it to be where we're running from, but + // where everything else came from. For now, let it be + // so that apr_dso_load() will do the right thing. This is + // going to be weird, because we have native code in both + // / as well as /default... FIXME + // + // const char* canoname = port_filepath_canonical(name, tmp_pool); + const char *canoname = name; // get library name from string pool @@ -1006,7 +1005,10 @@ // load native library bool just_loaded; NativeLoadStatus status; + // FIXME: add storing class loader here + p_TLS_vmthread->onload_caller = this; NativeLibraryHandle handle = natives_load_library(lib_name->bytes, &just_loaded, &status); + p_TLS_vmthread->onload_caller = NULL; if( !handle || !just_loaded ) { // create error message char apr_error_message[1024];