< prev index next >

src/hotspot/share/prims/jni.cpp

Print this page




 400       JavaValue result(T_OBJECT);
 401       JavaCalls::call_static(&result, k,
 402                              vmSymbols::getFromClass_name(),
 403                              vmSymbols::void_class_signature(),
 404                              CHECK_NULL);
 405       // When invoked from JNI_OnLoad, NativeLibrary::getFromClass returns
 406       // a non-NULL Class object.  When invoked from JNI_OnUnload,
 407       // it will return NULL to indicate no context.
 408       oop mirror = (oop) result.get_jobject();
 409       if (mirror != NULL) {
 410         Klass* fromClass = java_lang_Class::as_Klass(mirror);
 411         loader = Handle(THREAD, fromClass->class_loader());
 412         protection_domain = Handle(THREAD, fromClass->protection_domain());
 413       }
 414     } else {
 415       loader = Handle(THREAD, k->class_loader());
 416     }
 417   }
 418 
 419   TempNewSymbol sym = SymbolTable::new_symbol(name);
 420   result = find_class_from_class_loader(env, sym, true, loader,
 421                                         protection_domain, true, thread);
 422 
 423   if (log_is_enabled(Debug, class, resolve) && result != NULL) {
 424     trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result)));
 425   }
 426 
 427   return result;
 428 JNI_END
 429 
 430 DT_RETURN_MARK_DECL(FromReflectedMethod, jmethodID
 431                     , HOTSPOT_JNI_FROMREFLECTEDMETHOD_RETURN((uintptr_t)_ret_ref));
 432 
 433 JNI_ENTRY(jmethodID, jni_FromReflectedMethod(JNIEnv *env, jobject method))
 434   JNIWrapper("FromReflectedMethod");
 435 
 436   HOTSPOT_JNI_FROMREFLECTEDMETHOD_ENTRY(env, method);
 437 
 438   jmethodID ret = NULL;
 439   DT_RETURN_MARK(FromReflectedMethod, jmethodID, (const jmethodID&)ret);
 440 


3272 JNI_END
3273 
3274 
3275 // Initialization state for three routines below relating to
3276 // java.nio.DirectBuffers
3277 static          int directBufferSupportInitializeStarted = 0;
3278 static volatile int directBufferSupportInitializeEnded   = 0;
3279 static volatile int directBufferSupportInitializeFailed  = 0;
3280 static jclass    bufferClass                 = NULL;
3281 static jclass    directBufferClass           = NULL;
3282 static jclass    directByteBufferClass       = NULL;
3283 static jmethodID directByteBufferConstructor = NULL;
3284 static jfieldID  directBufferAddressField    = NULL;
3285 static jfieldID  bufferCapacityField         = NULL;
3286 
3287 static jclass lookupOne(JNIEnv* env, const char* name, TRAPS) {
3288   Handle loader;            // null (bootstrap) loader
3289   Handle protection_domain; // null protection domain
3290 
3291   TempNewSymbol sym = SymbolTable::new_symbol(name);
3292   jclass result =  find_class_from_class_loader(env, sym, true, loader, protection_domain, true, CHECK_NULL);
3293 
3294   if (log_is_enabled(Debug, class, resolve) && result != NULL) {
3295     trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result)));
3296   }
3297   return result;
3298 }
3299 
3300 // These lookups are done with the NULL (bootstrap) ClassLoader to
3301 // circumvent any security checks that would be done by jni_FindClass.
3302 JNI_ENTRY(bool, lookupDirectBufferClasses(JNIEnv* env))
3303 {
3304   if ((bufferClass           = lookupOne(env, "java/nio/Buffer", thread))           == NULL) { return false; }
3305   if ((directBufferClass     = lookupOne(env, "sun/nio/ch/DirectBuffer", thread))   == NULL) { return false; }
3306   if ((directByteBufferClass = lookupOne(env, "java/nio/DirectByteBuffer", thread)) == NULL) { return false; }
3307   return true;
3308 }
3309 JNI_END
3310 
3311 
3312 static bool initializeDirectBufferSupport(JNIEnv* env, JavaThread* thread) {




 400       JavaValue result(T_OBJECT);
 401       JavaCalls::call_static(&result, k,
 402                              vmSymbols::getFromClass_name(),
 403                              vmSymbols::void_class_signature(),
 404                              CHECK_NULL);
 405       // When invoked from JNI_OnLoad, NativeLibrary::getFromClass returns
 406       // a non-NULL Class object.  When invoked from JNI_OnUnload,
 407       // it will return NULL to indicate no context.
 408       oop mirror = (oop) result.get_jobject();
 409       if (mirror != NULL) {
 410         Klass* fromClass = java_lang_Class::as_Klass(mirror);
 411         loader = Handle(THREAD, fromClass->class_loader());
 412         protection_domain = Handle(THREAD, fromClass->protection_domain());
 413       }
 414     } else {
 415       loader = Handle(THREAD, k->class_loader());
 416     }
 417   }
 418 
 419   TempNewSymbol sym = SymbolTable::new_symbol(name);
 420   result = find_class_from_class_loader(env, sym, true, true, loader,
 421                                         protection_domain, true, thread);
 422 
 423   if (log_is_enabled(Debug, class, resolve) && result != NULL) {
 424     trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result)));
 425   }
 426 
 427   return result;
 428 JNI_END
 429 
 430 DT_RETURN_MARK_DECL(FromReflectedMethod, jmethodID
 431                     , HOTSPOT_JNI_FROMREFLECTEDMETHOD_RETURN((uintptr_t)_ret_ref));
 432 
 433 JNI_ENTRY(jmethodID, jni_FromReflectedMethod(JNIEnv *env, jobject method))
 434   JNIWrapper("FromReflectedMethod");
 435 
 436   HOTSPOT_JNI_FROMREFLECTEDMETHOD_ENTRY(env, method);
 437 
 438   jmethodID ret = NULL;
 439   DT_RETURN_MARK(FromReflectedMethod, jmethodID, (const jmethodID&)ret);
 440 


3272 JNI_END
3273 
3274 
3275 // Initialization state for three routines below relating to
3276 // java.nio.DirectBuffers
3277 static          int directBufferSupportInitializeStarted = 0;
3278 static volatile int directBufferSupportInitializeEnded   = 0;
3279 static volatile int directBufferSupportInitializeFailed  = 0;
3280 static jclass    bufferClass                 = NULL;
3281 static jclass    directBufferClass           = NULL;
3282 static jclass    directByteBufferClass       = NULL;
3283 static jmethodID directByteBufferConstructor = NULL;
3284 static jfieldID  directBufferAddressField    = NULL;
3285 static jfieldID  bufferCapacityField         = NULL;
3286 
3287 static jclass lookupOne(JNIEnv* env, const char* name, TRAPS) {
3288   Handle loader;            // null (bootstrap) loader
3289   Handle protection_domain; // null protection domain
3290 
3291   TempNewSymbol sym = SymbolTable::new_symbol(name);
3292   jclass result =  find_class_from_class_loader(env, sym, true, true, loader, protection_domain, true, CHECK_NULL);
3293 
3294   if (log_is_enabled(Debug, class, resolve) && result != NULL) {
3295     trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result)));
3296   }
3297   return result;
3298 }
3299 
3300 // These lookups are done with the NULL (bootstrap) ClassLoader to
3301 // circumvent any security checks that would be done by jni_FindClass.
3302 JNI_ENTRY(bool, lookupDirectBufferClasses(JNIEnv* env))
3303 {
3304   if ((bufferClass           = lookupOne(env, "java/nio/Buffer", thread))           == NULL) { return false; }
3305   if ((directBufferClass     = lookupOne(env, "sun/nio/ch/DirectBuffer", thread))   == NULL) { return false; }
3306   if ((directByteBufferClass = lookupOne(env, "java/nio/DirectByteBuffer", thread)) == NULL) { return false; }
3307   return true;
3308 }
3309 JNI_END
3310 
3311 
3312 static bool initializeDirectBufferSupport(JNIEnv* env, JavaThread* thread) {


< prev index next >