378 // Remember if we are the first invocation of jni_FindClass
379 bool first_time = first_time_FindClass;
380 first_time_FindClass = false;
381
382 // Sanity check the name: it cannot be null or larger than the maximum size
383 // name we can fit in the constant pool.
384 if (name == NULL || (int)strlen(name) > Symbol::max_length()) {
385 THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), name);
386 }
387
388 //%note jni_3
389 Handle loader;
390 Handle protection_domain;
391 // Find calling class
392 instanceKlassHandle k (THREAD, thread->security_get_caller_class(0));
393 if (k.not_null()) {
394 loader = Handle(THREAD, k->class_loader());
395 // Special handling to make sure JNI_OnLoad and JNI_OnUnload are executed
396 // in the correct class context.
397 if (loader.is_null() &&
398 k->name() == vmSymbols::java_lang_ClassLoader_NativeLibrary()) {
399 JavaValue result(T_OBJECT);
400 JavaCalls::call_static(&result, k,
401 vmSymbols::getFromClass_name(),
402 vmSymbols::void_class_signature(),
403 thread);
404 if (HAS_PENDING_EXCEPTION) {
405 Handle ex(thread, thread->pending_exception());
406 CLEAR_PENDING_EXCEPTION;
407 THROW_HANDLE_0(ex);
408 }
409 oop mirror = (oop) result.get_jobject();
410 loader = Handle(THREAD,
411 InstanceKlass::cast(java_lang_Class::as_Klass(mirror))->class_loader());
412 protection_domain = Handle(THREAD,
413 InstanceKlass::cast(java_lang_Class::as_Klass(mirror))->protection_domain());
414 }
415 } else {
416 // We call ClassLoader.getSystemClassLoader to obtain the system class loader.
417 loader = Handle(THREAD, SystemDictionary::java_system_loader());
418 }
|
378 // Remember if we are the first invocation of jni_FindClass
379 bool first_time = first_time_FindClass;
380 first_time_FindClass = false;
381
382 // Sanity check the name: it cannot be null or larger than the maximum size
383 // name we can fit in the constant pool.
384 if (name == NULL || (int)strlen(name) > Symbol::max_length()) {
385 THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), name);
386 }
387
388 //%note jni_3
389 Handle loader;
390 Handle protection_domain;
391 // Find calling class
392 instanceKlassHandle k (THREAD, thread->security_get_caller_class(0));
393 if (k.not_null()) {
394 loader = Handle(THREAD, k->class_loader());
395 // Special handling to make sure JNI_OnLoad and JNI_OnUnload are executed
396 // in the correct class context.
397 if (loader.is_null() &&
398 k->name()->equals(vmSymbols::java_lang_ClassLoader_NativeLibrary())) {
399 JavaValue result(T_OBJECT);
400 JavaCalls::call_static(&result, k,
401 vmSymbols::getFromClass_name(),
402 vmSymbols::void_class_signature(),
403 thread);
404 if (HAS_PENDING_EXCEPTION) {
405 Handle ex(thread, thread->pending_exception());
406 CLEAR_PENDING_EXCEPTION;
407 THROW_HANDLE_0(ex);
408 }
409 oop mirror = (oop) result.get_jobject();
410 loader = Handle(THREAD,
411 InstanceKlass::cast(java_lang_Class::as_Klass(mirror))->class_loader());
412 protection_domain = Handle(THREAD,
413 InstanceKlass::cast(java_lang_Class::as_Klass(mirror))->protection_domain());
414 }
415 } else {
416 // We call ClassLoader.getSystemClassLoader to obtain the system class loader.
417 loader = Handle(THREAD, SystemDictionary::java_system_loader());
418 }
|