380 } 381 if ((int)strlen(name) > Symbol::max_length()) { 382 Exceptions::fthrow(THREAD_AND_LOCATION, 383 vmSymbols::java_lang_NoClassDefFoundError(), 384 "Class name exceeds maximum length of %d: %s", 385 Symbol::max_length(), 386 name); 387 return 0; 388 } 389 390 //%note jni_3 391 Handle protection_domain; 392 // Find calling class 393 Klass* k = thread->security_get_caller_class(0); 394 // default to the system loader when no context 395 Handle loader(THREAD, SystemDictionary::java_system_loader()); 396 if (k != NULL) { 397 // Special handling to make sure JNI_OnLoad and JNI_OnUnload are executed 398 // in the correct class context. 399 if (k->class_loader() == NULL && 400 k->name() == vmSymbols::java_lang_ClassLoader_NativeLibrary()) { 401 JavaValue result(T_OBJECT); 402 JavaCalls::call_static(&result, k, 403 vmSymbols::getFromClass_name(), 404 vmSymbols::void_class_signature(), 405 CHECK_NULL); 406 // When invoked from JNI_OnLoad, NativeLibrary::getFromClass returns 407 // a non-NULL Class object. When invoked from JNI_OnUnload, 408 // it will return NULL to indicate no context. 409 oop mirror = (oop) result.get_jobject(); 410 if (mirror != NULL) { 411 Klass* fromClass = java_lang_Class::as_Klass(mirror); 412 loader = Handle(THREAD, fromClass->class_loader()); 413 protection_domain = Handle(THREAD, fromClass->protection_domain()); 414 } 415 } else { 416 loader = Handle(THREAD, k->class_loader()); 417 } 418 } 419 420 TempNewSymbol sym = SymbolTable::new_symbol(name); 421 result = find_class_from_class_loader(env, sym, true, loader, 422 protection_domain, true, thread); 423 424 if (log_is_enabled(Debug, class, resolve) && result != NULL) { 425 trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result))); 426 } | 380 } 381 if ((int)strlen(name) > Symbol::max_length()) { 382 Exceptions::fthrow(THREAD_AND_LOCATION, 383 vmSymbols::java_lang_NoClassDefFoundError(), 384 "Class name exceeds maximum length of %d: %s", 385 Symbol::max_length(), 386 name); 387 return 0; 388 } 389 390 //%note jni_3 391 Handle protection_domain; 392 // Find calling class 393 Klass* k = thread->security_get_caller_class(0); 394 // default to the system loader when no context 395 Handle loader(THREAD, SystemDictionary::java_system_loader()); 396 if (k != NULL) { 397 // Special handling to make sure JNI_OnLoad and JNI_OnUnload are executed 398 // in the correct class context. 399 if (k->class_loader() == NULL && 400 k->name() == vmSymbols::jdk_internal_loader_NativeLibraries()) { 401 JavaValue result(T_OBJECT); 402 JavaCalls::call_static(&result, k, 403 vmSymbols::getFromClass_name(), 404 vmSymbols::void_class_signature(), 405 CHECK_NULL); 406 // When invoked from JNI_OnLoad, NativeLibraries::getFromClass returns 407 // a non-NULL Class object. When invoked from JNI_OnUnload, 408 // it will return NULL to indicate no context. 409 oop mirror = (oop) result.get_jobject(); 410 if (mirror != NULL) { 411 Klass* fromClass = java_lang_Class::as_Klass(mirror); 412 loader = Handle(THREAD, fromClass->class_loader()); 413 protection_domain = Handle(THREAD, fromClass->protection_domain()); 414 } 415 } else { 416 loader = Handle(THREAD, k->class_loader()); 417 } 418 } 419 420 TempNewSymbol sym = SymbolTable::new_symbol(name); 421 result = find_class_from_class_loader(env, sym, true, loader, 422 protection_domain, true, thread); 423 424 if (log_is_enabled(Debug, class, resolve) && result != NULL) { 425 trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result))); 426 } |