< prev index next >

src/hotspot/share/prims/jni.cpp

Print this page




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


3191 JNI_END
3192 
3193 
3194 // Initialization state for three routines below relating to
3195 // java.nio.DirectBuffers
3196 static          int directBufferSupportInitializeStarted = 0;
3197 static volatile int directBufferSupportInitializeEnded   = 0;
3198 static volatile int directBufferSupportInitializeFailed  = 0;
3199 static jclass    bufferClass                 = NULL;
3200 static jclass    directBufferClass           = NULL;
3201 static jclass    directByteBufferClass       = NULL;
3202 static jmethodID directByteBufferConstructor = NULL;
3203 static jfieldID  directBufferAddressField    = NULL;
3204 static jfieldID  bufferCapacityField         = NULL;
3205 
3206 static jclass lookupOne(JNIEnv* env, const char* name, TRAPS) {
3207   Handle loader;            // null (bootstrap) loader
3208   Handle protection_domain; // null protection domain
3209 
3210   TempNewSymbol sym = SymbolTable::new_symbol(name);
3211   jclass result =  find_class_from_class_loader(env, sym, true, true, loader, protection_domain, true, CHECK_NULL);
3212 
3213   if (log_is_enabled(Debug, class, resolve) && result != NULL) {
3214     trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result)));
3215   }
3216   return result;
3217 }
3218 
3219 // These lookups are done with the NULL (bootstrap) ClassLoader to
3220 // circumvent any security checks that would be done by jni_FindClass.
3221 JNI_ENTRY(bool, lookupDirectBufferClasses(JNIEnv* env))
3222 {
3223   if ((bufferClass           = lookupOne(env, "java/nio/Buffer", thread))           == NULL) { return false; }
3224   if ((directBufferClass     = lookupOne(env, "sun/nio/ch/DirectBuffer", thread))   == NULL) { return false; }
3225   if ((directByteBufferClass = lookupOne(env, "java/nio/DirectByteBuffer", thread)) == NULL) { return false; }
3226   return true;
3227 }
3228 JNI_END
3229 
3230 
3231 static bool initializeDirectBufferSupport(JNIEnv* env, JavaThread* thread) {




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


3191 JNI_END
3192 
3193 
3194 // Initialization state for three routines below relating to
3195 // java.nio.DirectBuffers
3196 static          int directBufferSupportInitializeStarted = 0;
3197 static volatile int directBufferSupportInitializeEnded   = 0;
3198 static volatile int directBufferSupportInitializeFailed  = 0;
3199 static jclass    bufferClass                 = NULL;
3200 static jclass    directBufferClass           = NULL;
3201 static jclass    directByteBufferClass       = NULL;
3202 static jmethodID directByteBufferConstructor = NULL;
3203 static jfieldID  directBufferAddressField    = NULL;
3204 static jfieldID  bufferCapacityField         = NULL;
3205 
3206 static jclass lookupOne(JNIEnv* env, const char* name, TRAPS) {
3207   Handle loader;            // null (bootstrap) loader
3208   Handle protection_domain; // null protection domain
3209 
3210   TempNewSymbol sym = SymbolTable::new_symbol(name);
3211   jclass result =  find_class_from_class_loader(env, sym, true, loader, protection_domain, true, CHECK_NULL);
3212 
3213   if (log_is_enabled(Debug, class, resolve) && result != NULL) {
3214     trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result)));
3215   }
3216   return result;
3217 }
3218 
3219 // These lookups are done with the NULL (bootstrap) ClassLoader to
3220 // circumvent any security checks that would be done by jni_FindClass.
3221 JNI_ENTRY(bool, lookupDirectBufferClasses(JNIEnv* env))
3222 {
3223   if ((bufferClass           = lookupOne(env, "java/nio/Buffer", thread))           == NULL) { return false; }
3224   if ((directBufferClass     = lookupOne(env, "sun/nio/ch/DirectBuffer", thread))   == NULL) { return false; }
3225   if ((directByteBufferClass = lookupOne(env, "java/nio/DirectByteBuffer", thread)) == NULL) { return false; }
3226   return true;
3227 }
3228 JNI_END
3229 
3230 
3231 static bool initializeDirectBufferSupport(JNIEnv* env, JavaThread* thread) {


< prev index next >